Integrations and APIs for Service

Get Involved. Join the Conversation.


    Sreedhar Loorthu
    How to use CURLFile() with File Attachment of...
    Topic posted June 10, 2019 by Sreedhar Loorthu, tagged Connect PHP, Custom Process Models - CPMs, REST 
    54 Views, 1 Comment
    How to use CURLFile() with File Attachment of Incident
    Fetch File Attachment from Incident and Pass it to CURLFile() function using PHP
    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.
    array('file'=> new CURLFILE('imagefile.jpg'),
      'method' => 'method_name',
      'api_key' => 'XXXXXXXAPIKEYXXXXXXX',
      'body' => '{
    "type": "image", 
    "image" : {
    "caption" : "Image File"
    'from' => 'from_number',
    'format' => 'json')
    How to get the file from Incident and pass it to CURLFILE('') function?