Hi Puneet Jain
Thanks for reaching out on Microsoft Q&A!
Seems like the API is returning a response as binary, decoded, where logic apps wants a binary to be displayed as BASE64, thus throwing strange errors. I’ve had the same issue when calling the SharePoint CSOM API to retrieve a list attachment’s content.
There is no way to do this in a Logic App before the API is fixed, however you can add an API Management Service in between in the mean time to convert the response of the API to a byte array which makes the logic app interpret the file as it should.
By adding the snippet below to your APIM policy you should be able to get the contents properly:
<policies>
<inbound>
<base />
<set-backend-service base-url="https://graph.microsoft.com/v1.0" />
<rewrite-uri template="/teams/{team-id}/channels/{channel-id}/messages/{message-id}/hostedContents/{content-id}/$value" copy-unmatched-params="false" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<!-- Don't use the base as we don't want encoding to json -->
<!--<base />-->
<!-- Set value response as byte array -->
<set-body>@{
return context.Response.Body.As<Byte[]>();
}</set-body>
<!-- Set necessary headers -->
<set-header name="Content-Disposition" exists-action="delete" />
<set-header name="Content-Transfer-Encoding" exists-action="override">
<value>base64</value>
</set-header>
</outbound>
<on-error>
<base />
</on-error>
</policies>
Please click ‘Accept answer’ if you think my answer is helpful. Feel free to drop additional queries in the comments below!
Kind regards,
Sonny