Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Code
string ls_Created_time
string ls_File_id
string ls_Message
string ls_Status
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Req = create oleobject
// Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.HttpVerb = "POST"
loo_Req.Path = "/crm/v2/upload"
loo_Req.ContentType = "multipart/form-data"
li_Success = loo_Req.AddFileForUpload2("file"," path to file","application/octet-stream")
loo_Req.AddHeader("X-CRM-ORG","694902309")
loo_Req.AddHeader("Expect","100-continue")
loo_Req.AddHeader("feature","bulk-write")
loo_Req.AddHeader("Authorization","Bearer <access_token>")
loo_Resp = loo_Http.SynchronousRequest("content.zohoapis.com",443,1,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_Req
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "code": "FILE_UPLOAD_SUCCESS",
// "details": {
// "created_time": "2021-05-12T17:30:58+05:30",
// "file_id": "4150868000005379001"
// },
// "message": "file uploaded.",
// "status": "success"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Code = loo_JResp.StringOf("code")
ls_Created_time = loo_JResp.StringOf("details.created_time")
ls_File_id = loo_JResp.StringOf("details.file_id")
ls_Message = loo_JResp.StringOf("message")
ls_Status = loo_JResp.StringOf("status")
destroy loo_Http
destroy loo_Req
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "X-CRM-ORG: 694902309"
-H "feature: bulk-write"
--form 'file=@"/path/to/file"'
https://content.zohoapis.com/crm/v2/upload
Postman Collection Item JSON
{
"name": "Upload File",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{access-token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/SampleCsvFile.zip"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
},
"description": "To upload a CSV file in ZIP format for bulk write API. The response contains the **file_id**. Use this ID while making the bulk write request."
},
"response": [
{
"name": "SUCCESS RESPONSE",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/SampleCSVFile.zip"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 12 May 2021 05:00:58 PDT"
},
{
"key": "Last-Modified",
"value": "Wed, 12 May 2021 05:00:58 PDT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Connection",
"value": "Keep-Alive"
},
{
"key": "Server",
"value": "AWServer"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Request-Served-By",
"value": "US4"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Content-Length",
"value": "163"
},
{
"key": "Expires",
"value": "1"
}
],
"cookie": [
],
"body": "{\n \"code\": \"FILE_UPLOAD_SUCCESS\",\n \"details\": {\n \"created_time\": \"2021-05-12T17:30:58+05:30\",\n \"file_id\": \"4150868000005379001\"\n },\n \"message\": \"file uploaded.\",\n \"status\": \"success\"\n}"
},
{
"name": "INVALID_OAUTHTOKEN",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/File.zip"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
}
},
"status": "INVALID_OAUTHTOKEN",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 11 May 2021 08:57:07 PDT"
},
{
"key": "Last-Modified",
"value": "Tue, 11 May 2021 08:57:07 PDT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Connection",
"value": "Keep-Alive"
},
{
"key": "Server",
"value": "AWServer"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Request-Served-By",
"value": "US4"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "1"
}
],
"cookie": [
],
"body": "{\n \"ERROR_MESSAGE\": \"INVALID_OAUTHTOKEN\",\n \"ERROR_CODE\": 401\n}"
},
{
"name": "INVALID_FILE_FORMAT",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Downloads/_Bulk Write.erb"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 12 May 2021 05:01:25 PDT"
},
{
"key": "Last-Modified",
"value": "Wed, 12 May 2021 05:01:25 PDT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Connection",
"value": "Keep-Alive"
},
{
"key": "Server",
"value": "AWServer"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Request-Served-By",
"value": "US4"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Content-Length",
"value": "164"
},
{
"key": "Expires",
"value": "1"
}
],
"cookie": [
],
"body": "{\n \"code\": \"INVALID_FILE_FORMAT\",\n \"details\": {\n \"created_time\": \"2021-05-12T17:31:25+05:30\"\n },\n \"message\": \"invalid file format. only zip format is supported\",\n \"status\": \"error\"\n}"
},
{
"name": "METHOD_NOT_ALLOWED",
"originalRequest": {
"method": "PUT",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/SampleCsvFile.zip"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
}
},
"status": "Method Not AllowedDate: Wed May 12 05:01:56 PDT 2021",
"code": 405,
"_postman_previewlanguage": "plain",
"header": [
],
"cookie": [
],
"body": null
},
{
"name": "UNAUTHORIZED",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "X-CRM-ORG",
"value": "694902309",
"type": "text"
},
{
"key": "feature",
"value": "bulk-write",
"type": "text"
},
{
"key": "",
"value": "",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"type": "file",
"src": "/Users/sneha-9300/Desktop/SampleCsvFile.zip"
}
]
},
"url": {
"raw": "https://content.zohoapis.com/crm/v2/upload",
"protocol": "https",
"host": [
"content",
"zohoapis",
"com"
],
"path": [
"crm",
"v2",
"upload"
]
}
},
"status": "Unauthorized Error",
"code": 401,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Wed, 12 May 2021 05:02:17 PDT"
},
{
"key": "Last-Modified",
"value": "Wed, 12 May 2021 05:02:17 PDT"
},
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Connection",
"value": "Keep-Alive"
},
{
"key": "Server",
"value": "AWServer"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=15768000"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Request-Served-By",
"value": "US4"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Expires",
"value": "1"
}
],
"cookie": [
],
"body": "{\n \"ERROR_MESSAGE\": \"Unauthorized Error\",\n \"ERROR_CODE\": 401\n}"
}
]
}