Share via


how to save file as pdf from binary output using logic app

Question

Friday, August 9, 2019 12:49 PM

I have HTTP connector which is giving output as -

{"statusCode":200,"headers":{"dataserviceversion":"2.0","sap-metadata-last-modified":"Fri, 09 Aug 2019 10:41:57 GMT","Cache-Control":"no-store, no-cache","Date":"Fri, 09 Aug 2019 11:26:58 GMT","Content-Type":"application/atom+xml; type=feed; charset=utf-8","Content-Length":"1365811"},"body":{"$content-type":"application/atom+xml; type=feed; charset=utf-8","$content":"PGZlZWQgeG1sbn"

$content is having binary data which is nothing but pdf file.

note - content-type is  application/atom+xml

I want to get this data and convert it into pdf file

into sharepoint connector while create pdf file i send body('HTTP')?['content'] still unable to create a valid pdf file.

while opening file it throws error -

in sharepoint create file connector i'm passing that binary string like - base64ToBinary(thatBinaryValue) but in sharepoint type is

 "$content-type": "application/octet-stream",

SE

All replies (4)

Friday, August 9, 2019 4:40 PM

I believe binary data is converted into base64 when processed by logic apps. So, in the sharepoint action, you would have to use the base64ToBinary() function to get it to work.


Monday, August 12, 2019 8:23 AM

I tried using base64ToBinary also but able to generate pdf file but while open same error getting...

body('HTTP') output is -

{"statusCode":200,"headers":{"dataserviceversion":"2.0","sap-metadata-last-modified":"Fri, 09 Aug 2019 10:41:57 GMT","Cache-Control":"no-store, no-cache","Date":"Fri, 09 Aug 2019 11:26:58 GMT","Content-Type":"application/atom+xml; type=feed; charset=utf-8","Content-Length":"1365811"},"body":{"$content-type":"application/atom+xml; type=feed; charset=utf-8","$content":"PGZlZWQgeG1sbn

SE


Monday, August 12, 2019 2:29 PM

I believe the expression you would need to use is base64ToBinary(body('HTTP')['$content']), since the output from the HTTP action is handled differently since its not a known type.


Tuesday, August 13, 2019 4:46 PM

updated question with sharepoint connector image pls check

SE