Sample code for 30+ languages & platforms
Xojo Plugin

IntakeQ: Send a Questionnaire

See more IntakeQ Examples

Send an intake package using the API.

Chilkat Xojo Plugin Downloads

Xojo Plugin
Dim success As Boolean
success = False

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Dim http As New Chilkat.Http

// 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"
// }

Dim json As New Chilkat.JsonObject
success = json.UpdateString("QuestionnaireId","00000000-0000-0000-0000-000000000000")
success = json.UpdateInt("ClientId",123)
success = json.UpdateString("ClientName","Dexter Morgan")
success = json.UpdateString("ClientEmail","dexter@email.com")
success = json.UpdateString("ClientPhone","2222222222")
success = json.UpdateString("PractitionerId","00000000-0000-0000-0000-000000000000")

http.SetRequestHeader "Content-Type","application/json"
http.SetRequestHeader "X-Auth-Key","xxxxxxxxxxxxxxxxxxxxxxxxx"

Dim resp As New Chilkat.HttpResponse
success = http.HttpJson("POST","https://intakeq.com/api/v1/intakes/send",json,"application/json",resp)
If (success = False) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)
Dim jResp As New Chilkat.JsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = False

System.DebugLog("Response Body:")
System.DebugLog(jResp.Emit())

Dim respStatusCode As Int32
respStatusCode = resp.StatusCode
System.DebugLog("Response Status Code = " + Str(respStatusCode))
If (respStatusCode >= 400) Then
    System.DebugLog("Response Header:")
    System.DebugLog(resp.Header)
    System.DebugLog("Failed.")
    Return
End If

// 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

Dim Text As String
Dim Answer As String
Dim QuestionType As String
Dim OfficeUse As Boolean
Dim OfficeNote As String
Dim j As Int32
Dim count_j As Int32
Dim Name As String
Dim DocumentType As String
Dim Signed As Boolean

Dim Id As String
Id = jResp.StringOf("Id")
Dim ClientName As String
ClientName = jResp.StringOf("ClientName")
Dim ClientEmail As String
ClientEmail = jResp.StringOf("ClientEmail")
Dim ClientId As Int32
ClientId = jResp.IntOf("ClientId")
Dim Status As String
Status = jResp.StringOf("Status")
Dim DateCreated As Int32
DateCreated = jResp.IntOf("DateCreated")
Dim DateSubmitted As Int32
DateSubmitted = jResp.IntOf("DateSubmitted")
Dim QuestionnaireName As String
QuestionnaireName = jResp.StringOf("QuestionnaireName")
Dim Practitioner As String
Practitioner = jResp.StringOf("Practitioner")
Dim PractitionerName As String
PractitionerName = jResp.StringOf("PractitionerName")
Dim AppointmentId As String
AppointmentId = jResp.StringOf("AppointmentId")
Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jResp.SizeOfArray("Questions")
While i < count_i
    jResp.I = i
    Id = jResp.StringOf("Questions[i].Id")
    Text = jResp.StringOf("Questions[i].Text")
    Answer = jResp.StringOf("Questions[i].Answer")
    QuestionType = jResp.StringOf("Questions[i].QuestionType")
    OfficeUse = jResp.BoolOf("Questions[i].OfficeUse")
    OfficeNote = jResp.StringOf("Questions[i].OfficeNote")
    j = 0
    count_j = jResp.SizeOfArray("Questions[i].Rows")
    While j < count_j
        jResp.J = j
        j = j + 1
    Wend
    j = 0
    count_j = jResp.SizeOfArray("Questions[i].ColumnNames")
    While j < count_j
        jResp.J = j
        j = j + 1
    Wend
    i = i + 1
Wend
i = 0
count_i = jResp.SizeOfArray("ConsentForms")
While i < count_i
    jResp.I = i
    Id = jResp.StringOf("ConsentForms[i].Id")
    Name = jResp.StringOf("ConsentForms[i].Name")
    DocumentType = jResp.StringOf("ConsentForms[i].DocumentType")
    Signed = jResp.BoolOf("ConsentForms[i].Signed")
    DateSubmitted = jResp.IntOf("ConsentForms[i].DateSubmitted")
    i = i + 1
Wend