Chilkat Online Tools

PowerBuilder / Zoho CRM REST APIs / Events

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Req
oleobject loo_Resp

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat_9_5_0.HttpRequest")

loo_Req.HttpVerb = "POST"
loo_Req.Path = "/crm/v2/Events/{{record_id}}/Attachments"
loo_Req.ContentType = "multipart/form-data"
li_Success = loo_Req.AddFileForUpload2("file"," path to file","application/octet-stream")

loo_Req.AddHeader("Authorization","Bearer <access_token>")
loo_Req.AddHeader("Expect","100-continue")

loo_Resp = loo_Http.SynchronousRequest("domain.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

Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp


destroy loo_Http
destroy loo_Req

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	--form 'file=@"/path/to/file"'
https://domain.com/crm/v2/Events/{{record_id}}/Attachments

Postman Collection Item JSON

{
  "name": "Events",
  "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/Events/{{record_id}}/Attachments",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "Events",
        "{{record_id}}",
        "Attachments"
      ]
    },
    "description": "To attach a file to a record. You must include the attachment in the request with content type as multipart/form data."
  },
  "response": [
  ]
}