Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    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
    Title:
    How to use CURLFile() with File Attachment of Incident
    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?

    Comment