Jump to content

Trying to save the sales_invoice as pdf file to blob storage using C# Client, but getting 406:not acceptable error.


 Share

Recommended Posts

I am using v3.1 api and making the call to "sale_invoice/{id}.pdf" with headers "application/pdf". My target is to read the file bytes and save the filebytes to new file on blob storage but failing to do so.  

From debugging, I noticed that C# client is throwing 406: response (Not acceptable). Tried in postman and response was same again. I can view the file in chrome browser once user is logged in. I did not notice anything different in request header in comparison to Google chrome headers.

PFA for the postman request. 

Regards,

Screenshot 2023-08-22 114644.png

Link to comment
Share on other sites

Hi Rasphal,

Thank you for your question. You'll need to make a get request to sales_invoices/id and replace the request header Accept:application/json with Accept:application/pdf.

It look as if you're trying to add pdf as a query param in the url currently which may be the cause of your error.

The response will then provide you with the invoice in a PDF format.

Thanks

Mark

Link to comment
Share on other sites

Thank you, Mark,

Although now I found the solution also. As your solution suggest I need to remove the pdf extension from request Uri and I also need to change the base Uri to the Api request Uri, (as the one shown in image is not Api request Uri) After that I was able to get the bytes [] successfully. Accept Header I used for all my request has always been set to application/pdf

Thank you for your help.

Regards,
Rashpal 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...