Back to Collection Items
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]
CkHttp_put_BasicAuth $http 1
CkHttp_put_Login $http "{{api_key}}"
CkHttp_put_Password $http "{{api_secret}}"
# Use this online tool to generate code from sample JSON: Generate Code to Create JSON
# The following JSON is sent in the request body.
# [
# {
# "document_type": "cip_result",
# "content": "VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=",
# "mime_type": "application/pdf"
# },
# {
# "document_type": "identity_verification",
# "document_sub_type": "passport",
# "content": "QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=",
# "mime_type": "image/jpeg"
# }
# ]
set jarr [new_CkJsonArray]
CkJsonArray_AddObjectAt $jarr -1
# jsonObj_1 is a CkJsonObject
set jsonObj_1 [CkJsonArray_ObjectAt $jarr [expr [CkJsonArray_get_Size $jarr] - 1]]
CkJsonObject_UpdateString $jsonObj_1 "document_type" "cip_result"
CkJsonObject_UpdateString $jsonObj_1 "content" "VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4="
CkJsonObject_UpdateString $jsonObj_1 "mime_type" "application/pdf"
delete_CkJsonObject $jsonObj_1
CkJsonArray_AddObjectAt $jarr -1
set jsonObj_1 [CkJsonArray_ObjectAt $jarr [expr [CkJsonArray_get_Size $jarr] - 1]]
CkJsonObject_UpdateString $jsonObj_1 "document_type" "identity_verification"
CkJsonObject_UpdateString $jsonObj_1 "document_sub_type" "passport"
CkJsonObject_UpdateString $jsonObj_1 "content" "QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4="
CkJsonObject_UpdateString $jsonObj_1 "mime_type" "image/jpeg"
delete_CkJsonObject $jsonObj_1
set sbRequestBody [new_CkStringBuilder]
CkJsonArray_EmitSb $jarr $sbRequestBody
# resp is a CkHttpResponse
set resp [CkHttp_PTextSb $http "POST" "https://domain.com/v1/accounts/:account_id/documents/upload" $sbRequestBody "utf-8" "application/json" 0 0]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkJsonArray $jarr
delete_CkStringBuilder $sbRequestBody
exit
}
puts [CkHttpResponse_get_StatusCode $resp]
puts [CkHttpResponse_bodyStr $resp]
delete_CkHttpResponse $resp
delete_CkHttp $http
delete_CkJsonArray $jarr
delete_CkStringBuilder $sbRequestBody
Curl Command
curl -X POST
-u '{{api_key}}:{{api_secret}}'
-d '[
{
"document_type": "cip_result",
"content": "VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=",
"mime_type": "application/pdf"
},
{
"document_type": "identity_verification",
"document_sub_type": "passport",
"content": "QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=",
"mime_type": "image/jpeg"
}
]'
https://domain.com/v1/accounts/:account_id/documents/upload
Postman Collection Item JSON
{
"name": "Document",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "[\n {\n \"document_type\": \"cip_result\",\n \"content\": \"VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=\",\n \"mime_type\": \"application/pdf\"\n },\n {\n \"document_type\": \"identity_verification\",\n \"document_sub_type\": \"passport\",\n \"content\": \"QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=\",\n \"mime_type\": \"image/jpeg\"\n }\n]",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{HOST}}/v1/accounts/:account_id/documents/upload",
"host": [
"{{HOST}}"
],
"path": [
"v1",
"accounts",
":account_id",
"documents",
"upload"
],
"variable": [
{
"key": "account_id",
"value": null
}
]
},
"description": "| Key | Value | Requirement |\n|-------------------|-----------------------|:-----------:|\n| `document_upload` | models.DocumentUpload | Required |"
},
"response": [
]
}