(PureBasic) Download Full Intake Form in JSON Format
The full intake form is very similar to intake summary object, except it adds an array of questions. For more information, see https://support.intakeq.com/article/31-intakeq-api#download-intake
IncludeFile "CkHttp.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkJsonObject.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; To log the exact HTTP request/response to a session log file:
CkHttp::setCkSessionLogFilename(http, "/someDir/sessionLog.txt")
CkHttp::ckSetRequestHeader(http,"X-Auth-Key","xxxxxxxxxxxxxxxxxxxxxxxxx")
sbJson.i = CkStringBuilder::ckCreate()
If sbJson.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i = CkHttp::ckQuickGetSb(http,"https://intakeq.com/api/v1/intakes/[intake-id]",sbJson)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
If CkHttp::ckLastStatus(http) <> 200
Debug "status code: " + Str(CkHttp::ckLastStatus(http))
Debug "response: " + CkStringBuilder::ckGetAsString(sbJson)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbJson)
ProcedureReturn
EndIf
Debug "raw response: "
Debug CkStringBuilder::ckGetAsString(sbJson)
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(json,sbJson)
CkJsonObject::setCkEmitCompact(json, 1)
Debug CkJsonObject::ckEmit(json)
CkHttp::ckDispose(http)
CkStringBuilder::ckDispose(sbJson)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndProcedure
|