Back to Collection Items
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess
$oReq = ObjCreate("Chilkat.HttpRequest")
$oReq.HttpVerb = "POST"
$oReq.Path = "/crm/v2/Accounts/{{record_id}}/photo"
$oReq.ContentType = "multipart/form-data"
$bSuccess = $oReq.AddFileForUpload2("file"," path to file","application/octet-stream")
$oReq.AddHeader "Authorization","Bearer <access_token>"
$oReq.AddHeader "Expect","100-continue"
Local $oResp = $oHttp.SynchronousRequest("domain.com",443,True,$oReq)
If ($oHttp.LastMethodSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
--form 'file=@"/path/to/file"'
https://domain.com/crm/v2/Accounts/{{record_id}}/photo
Postman Collection Item JSON
{
"name": "Accounts",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/image.jpg"
}
]
},
"url": {
"raw": "{{api-domain}}/crm/v2/Accounts/{{record_id}}/photo",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2",
"Accounts",
"{{record_id}}",
"photo"
]
},
"description": "To add record image to the record. You must include the photo in the request with content type as multipart/form data."
},
"response": [
]
}