Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) 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
#include <CkHttp.h> #include <CkJsonObject.h> #include <CkHttpResponse.h> #include <CkStringBuilder.h> void ChilkatSample(void) { CkString strOut; // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; bool success; // 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" // } CkJsonObject json; json.UpdateString("QuestionnaireId","00000000-0000-0000-0000-000000000000"); json.UpdateInt("ClientId",123); json.UpdateString("ClientName","Dexter Morgan"); json.UpdateString("ClientEmail","dexter@email.com"); json.UpdateString("ClientPhone","2222222222"); json.UpdateString("PractitionerId","00000000-0000-0000-0000-000000000000"); http.SetRequestHeader("Content-Type","application/json"); http.SetRequestHeader("X-Auth-Key","xxxxxxxxxxxxxxxxxxxxxxxxx"); CkHttpResponse *resp = http.PostJson3("https://intakeq.com/api/v1/intakes/send","application/json",json); if (http.get_LastMethodSuccess() == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkStringBuilder sbResponseBody; resp->GetBodySb(sbResponseBody); CkJsonObject jResp; jResp.LoadSb(sbResponseBody); jResp.put_EmitCompact(false); strOut.append("Response Body:"); strOut.append("\r\n"); strOut.append(jResp.emit()); strOut.append("\r\n"); int respStatusCode = resp->get_StatusCode(); strOut.append("Response Status Code = "); strOut.appendInt(respStatusCode); strOut.append("\r\n"); if (respStatusCode >= 400) { strOut.append("Response Header:"); strOut.append("\r\n"); strOut.append(resp->header()); strOut.append("\r\n"); strOut.append("Failed."); strOut.append("\r\n"); delete resp; SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } delete 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 // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const char *Text = 0; const char *Answer = 0; const char *QuestionType = 0; bool OfficeUse; const char *OfficeNote = 0; int j; int count_j; const char *Name = 0; const char *DocumentType = 0; bool Signed; const char *Id = jResp.stringOf("Id"); const char *ClientName = jResp.stringOf("ClientName"); const char *ClientEmail = jResp.stringOf("ClientEmail"); int ClientId = jResp.IntOf("ClientId"); const char *Status = jResp.stringOf("Status"); int DateCreated = jResp.IntOf("DateCreated"); int DateSubmitted = jResp.IntOf("DateSubmitted"); const char *QuestionnaireName = jResp.stringOf("QuestionnaireName"); const char *Practitioner = jResp.stringOf("Practitioner"); const char *PractitionerName = jResp.stringOf("PractitionerName"); const char *AppointmentId = jResp.stringOf("AppointmentId"); int i = 0; int count_i = jResp.SizeOfArray("Questions"); while (i < count_i) { jResp.put_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.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("Questions[i].ColumnNames"); while (j < count_j) { jResp.put_J(j); j = j + 1; } i = i + 1; } i = 0; count_i = jResp.SizeOfArray("ConsentForms"); while (i < count_i) { jResp.put_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; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.