Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) IntakeQ: Send a QuestionnaireSee more IntakeQ ExamplesSend an intake package using the API. For more information, see https://support.intakeq.com/article/31-intakeq-api#send-questionnaire
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # Implements the following CURL command: # curl -H "Content-Type: application/json" \ # -H 'X-Auth-Key: xxxxxxxxxxxxxxxxxxxxxxxxx' \ # -X POST \ # -d '{ # "QuestionnaireId": "00000000-0000-0000-0000-000000000000", # "ClientId": 123, # "ClientName": "Dexter Morgan", # "ClientEmail": "dexter@email.com", # "ClientPhone": "2222222222", # "PractitionerId": "00000000-0000-0000-0000-000000000000", # }' https://intakeq.com/api/v1/intakes/send # Use the following online tool to generate HTTP code from a CURL command # Convert a cURL Command to HTTP Source Code # Use this online tool to generate code from sample JSON: # Generate Code to Create JSON # The following JSON is sent in the request body. # { # "QuestionnaireId": "00000000-0000-0000-0000-000000000000", # "ClientId": 123, # "ClientName": "Dexter Morgan", # "ClientEmail": "dexter@email.com", # "ClientPhone": "2222222222", # "PractitionerId": "00000000-0000-0000-0000-000000000000" # } set json [new_CkJsonObject] CkJsonObject_UpdateString $json "QuestionnaireId" "00000000-0000-0000-0000-000000000000" CkJsonObject_UpdateInt $json "ClientId" 123 CkJsonObject_UpdateString $json "ClientName" "Dexter Morgan" CkJsonObject_UpdateString $json "ClientEmail" "dexter@email.com" CkJsonObject_UpdateString $json "ClientPhone" "2222222222" CkJsonObject_UpdateString $json "PractitionerId" "00000000-0000-0000-0000-000000000000" CkHttp_SetRequestHeader $http "Content-Type" "application/json" CkHttp_SetRequestHeader $http "X-Auth-Key" "xxxxxxxxxxxxxxxxxxxxxxxxx" # resp is a CkHttpResponse set resp [CkHttp_PostJson3 $http "https://intakeq.com/api/v1/intakes/send" "application/json" $json] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkJsonObject $json exit } set sbResponseBody [new_CkStringBuilder] CkHttpResponse_GetBodySb $resp $sbResponseBody set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] set respStatusCode [CkHttpResponse_get_StatusCode $resp] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttpResponse_header $resp] puts "Failed." delete_CkHttpResponse $resp delete_CkHttp $http delete_CkJsonObject $json delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp exit } delete_CkHttpResponse $resp # Sample JSON response: # (Sample code for parsing the JSON response is shown below) # { # "Id": "00000000-0000-0000-0000-000000000000", # "ClientName": "test", # "ClientEmail": "test@email.com", # "ClientId": 9999, # "Status": "Completed", # "DateCreated": 1458526480368, # "DateSubmitted": 1458526532654, # "QuestionnaireName": "test", # "Practitioner": "test@email.com", # "PractitionerName": "FirstName LastName", # "Questions": [ # { # "Id": "xxxx-1", # "Text": "Full name", # "Answer": "Dexter Morgan", # "QuestionType": "OpenQuestion", # "Rows": [ # ], # "ColumnNames": [ # ], # "OfficeUse": false, # "OfficeNote": "aaa" # }, # { # "Id": "xxxx-2", # "Text": "Full name", # "Answer": "Dexter Morgan", # "QuestionType": "OpenQuestion", # "Rows": [ # ], # "ColumnNames": [ # ], # "OfficeUse": false, # "OfficeNote": "aaa" # } # ], # "AppointmentId": "xxxxxxxx", # "ConsentForms": [ # { # "Id": "00000000-0000-0000-0000-000000000000", # "Name": "HIPAA Release Form", # "DocumentType": "Html", # "Signed": true, # "DateSubmitted": 1458526532654 # } # ] # } # Sample code for parsing the JSON response... # Use the following online tool to generate parsing code from sample JSON: # Generate Parsing Code from JSON set Id [CkJsonObject_stringOf $jResp "Id"] set ClientName [CkJsonObject_stringOf $jResp "ClientName"] set ClientEmail [CkJsonObject_stringOf $jResp "ClientEmail"] set ClientId [CkJsonObject_IntOf $jResp "ClientId"] set Status [CkJsonObject_stringOf $jResp "Status"] set DateCreated [CkJsonObject_IntOf $jResp "DateCreated"] set DateSubmitted [CkJsonObject_IntOf $jResp "DateSubmitted"] set QuestionnaireName [CkJsonObject_stringOf $jResp "QuestionnaireName"] set Practitioner [CkJsonObject_stringOf $jResp "Practitioner"] set PractitionerName [CkJsonObject_stringOf $jResp "PractitionerName"] set AppointmentId [CkJsonObject_stringOf $jResp "AppointmentId"] set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "Questions"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set Id [CkJsonObject_stringOf $jResp "Questions[i].Id"] set Text [CkJsonObject_stringOf $jResp "Questions[i].Text"] set Answer [CkJsonObject_stringOf $jResp "Questions[i].Answer"] set QuestionType [CkJsonObject_stringOf $jResp "Questions[i].QuestionType"] set OfficeUse [CkJsonObject_BoolOf $jResp "Questions[i].OfficeUse"] set OfficeNote [CkJsonObject_stringOf $jResp "Questions[i].OfficeNote"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "Questions[i].Rows"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "Questions[i].ColumnNames"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set j [expr $j + 1] } set i [expr $i + 1] } set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "ConsentForms"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set Id [CkJsonObject_stringOf $jResp "ConsentForms[i].Id"] set Name [CkJsonObject_stringOf $jResp "ConsentForms[i].Name"] set DocumentType [CkJsonObject_stringOf $jResp "ConsentForms[i].DocumentType"] set Signed [CkJsonObject_BoolOf $jResp "ConsentForms[i].Signed"] set DateSubmitted [CkJsonObject_IntOf $jResp "ConsentForms[i].DateSubmitted"] set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $json delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.