Back to Collection Items
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttpRequest.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
success.i
req.i = CkHttpRequest::ckCreate()
If req.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpRequest::setCkHttpVerb(req, "PUT")
CkHttpRequest::setCkPath(req, "/invoices/:id/image_scan?return_object=limited")
CkHttpRequest::setCkContentType(req, "multipart/form-data")
success = CkHttpRequest::ckAddFileForUpload2(req,"file"," path to file","application/octet-stream")
CkHttpRequest::ckAddHeader(req,"Authorization","Bearer <access_token>")
CkHttpRequest::ckAddHeader(req,"Expect","100-continue")
resp.i = CkHttp::ckSynchronousRequest(http,"domain.com",443,1,req)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
ProcedureReturn
EndIf
Debug Str(CkHttpResponse::ckStatusCode(resp))
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkHttpRequest::ckDispose(req)
ProcedureReturn
EndProcedure
Curl Command
curl -X PUT
-H "Authorization: Bearer <access_token>"
--form 'file=@"/path/to/file"'
https://domain.com/invoices/:id/image_scan?return_object=limited
Postman Collection Item JSON
{
"name": "Update Image Scan on an Invoice",
"protocolProfileBehavior": {
"disabledSystemHeaders": {}
},
"request": {
"method": "PUT",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"description": "\"Body Params: Form_data\nParam Name: file\nParam Type: file\nParam Value: Choose File\"",
"type": "file",
"src": "/Users/siyadmohammed/Documents/Learning/EmptyFiles/Test.pdf"
}
]
},
"url": {
"raw": "{{URL}}/invoices/:id/image_scan?return_object=limited",
"host": [
"{{URL}}"
],
"path": [
"invoices",
":id",
"image_scan"
],
"query": [
{
"key": "return_object",
"value": "limited"
}
],
"variable": [
{
"key": "id",
"value": "1291"
}
]
}
},
"response": [
]
}