Back to Collection Items
' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim http As New ChilkatHttp
Dim success As Long
http.BasicAuth = 1
http.Login = "{{api_key}}"
http.Password = "{{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"
' }
' ]
Dim jarr As New ChilkatJsonArray
success = jarr.AddObjectAt(-1)
Dim jsonObj_1 As ChilkatJsonObject
Set jsonObj_1 = jarr.ObjectAt(jarr.Size - 1)
success = jsonObj_1.UpdateString("document_type","cip_result")
success = jsonObj_1.UpdateString("content","VGhlcmUgYXJlIG5vIHdpbGQgYWxwYWNhcy4=")
success = jsonObj_1.UpdateString("mime_type","application/pdf")
success = jarr.AddObjectAt(-1)
Set jsonObj_1 = jarr.ObjectAt(jarr.Size - 1)
success = jsonObj_1.UpdateString("document_type","identity_verification")
success = jsonObj_1.UpdateString("document_sub_type","passport")
success = jsonObj_1.UpdateString("content","QWxwYWNhcyBjYW5ub3QgbGl2ZSBhbG9uZS4=")
success = jsonObj_1.UpdateString("mime_type","image/jpeg")
Dim sbRequestBody As New ChilkatStringBuilder
success = jarr.EmitSb(sbRequestBody)
Dim resp As ChilkatHttpResponse
Set resp = http.PTextSb("POST","https://domain.com/v1/accounts/:account_id/documents/upload",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
Debug.Print http.LastErrorText
Exit Sub
End If
Debug.Print resp.StatusCode
Debug.Print resp.BodyStr
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": [
]
}