We'd love to hear from you! Provide  feedback  to earn a badge today. Take our quick survey
You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register

How to use CURLFile() with File Attachment of Incident

Received Response
33
Views
1
Comments
edited Jun 10, 2019 1:09PM in Integrations and APIs 1 comment

Summary

Fetch File Attachment from Incident and Pass it to CURLFile() function using PHP

Content

As part of Integration, I need to pass an image file to REST API. 
It was recommended to use CURLFile('') function for assigning file.
So, I need to get the file from a particular Incident's FileAttachment and assign it in JSON using PHP.
Find the bleow sample code for CURLOPT_POSTFIELDS.
 
CURLOPT_POSTFIELDS:
 
array('file'=> new CURLFILE('imagefile.jpg'),
  'method' => 'method_name',
  'api_key' => 'XXXXXXXAPIKEYXXXXXXX',
  'body' => '{
"to":"to_number",
"type": "image", 
"image" : {
"caption" : "Image File"
},
}',
'from' => 'from_number',
'format' => 'json')
 
 
How to get the file from Incident and pass it to CURLFILE('') function?

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!