Sending attachment data via REST service
Hello - I am trying to send a PDF in a REST service response to an external system but unable to do so. I get the error message
"Invalid parameter passed for method: SetValue of Document Primitive: file_data. (2,1016)"
FYI, I have created a document based message with file_data as one of the fields as shown in the screenshot below
the assignment is done via this line of code
&ComResp_Level1_Item.GetPropertyByName("file_data").Value = &Doc_Data;
where &Doc_Data is populated from FILE_DATA field via a sql object as shown below
SELECT ATTACHSYSFILENAME ,FILE_SEQ ,FILE_DATA FROM %Table(:1) WHERE ATTACHSYSFILENAME = :2
When I comment the above mentioned peoplecode, the service returns data pertaining all other fields correctly, however when I uncomment that line, then the service errors.
Any help is greatly appreciated. Thanks.
Answers
-
Please review "E-IB: Is it Possible to Receive a 3rd Party Pdf File Via REST Service? (Doc ID 2724854.1)"
0 -
It depends on the PDF. Modern PDFs are usually binary. The PDF spec, however, is text-based. If you have a text-based PDF, then yes, absolutely you may insert the PDF text into the Document. Otherwise, the code will fail because PeopleCode doesn't have facilities for handling binary data. The alternative is to base64 encode binary data, which is certainly possible, but would require both sides of the integration to understand that base64 is expected.
0

