Let's Reconnect, thank you for making 2022 our best year yet.

Look Back
What is the content type for pdf while creating attachment via connect PHP/Rest API? — Cloud Customer Connect
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

What is the content type for pdf while creating attachment via connect PHP/Rest API?

Accepted answer
24
Views
9
Comments
edited Jun 13, 2022 4:10AM in General Technical Discussions 9 comments

Content

Hi All,

Please let me know whats the content type for pdf while creating the file attachment? 

I have tried with the following lines,

$fattach->ContentType = "application/pdf;

$fattach->ContentType = "application/x-pdf;

 

The file getting created and attached to the incident successfully, but when I open its showing the attached error,

 

Version

Aug 2017

Code Snippet

             $dynamic_content="Sample content to create PDF file from CPHP";
$incident=RNCPHP\Incident::fetch(1059);
$incident->FileAttachments =new RNCPHP\FileAttachmentIncidentArray();
$fattach = new RNCPHP\FileAttachmentIncident();
$fattach->ContentType = "application/pdf";
$fp = $fattach->makeFile();
fwrite( $fp, "$dynamic_content");
fclose( $fp );
$fattach->FileName = "NewTextFile".date("Y-m-d_h_i_s").".pdf";
$fattach->Name = "New Text File ".date("Y-m-d h:i:s").".pdf";
$incident->FileAttachments[] = $fattach;
$incident->save(); 
        

Howdy, Stranger!

Log In

To view full details, sign in.

Register

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