AZURE REST API - How to upload PDF using base64?

2024-07-09T17:51:18.69+00:00

I'm trying to upload pdf files to a storage account using the azure rest api.

I can upload the files using binary, but when uploading using base64 my file seems to be corrupted in the upload process.

The file sending process gives me a status of 201 (201 Created), but when downloading the file to Azure, I receive an error saying: Failed to load the PDF document.
requests and prints below:

prova 1 rest api

prova 2 rest api

prova 3 rest api

curl:

curl --location --request PUT 'https://

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,842 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 54,316 Reputation points
    2024-07-09T19:44:05.11+00:00

    This question is really about Postman and not a MS product. You should ask in their forum. If you check in their forums there are several questions related to this and several solutions. Here is one of many - link.

    0 comments No comments

  2. Ryan Hill 28,106 Reputation points Microsoft Employee
    2024-07-09T21:45:34.78+00:00

    Hi @GUILHERME RODRIGUES SILVA DE JESUS

    After reviewing Put Blob (REST API) - Azure Storage | Microsoft Learn, one thing I can suggestion is verifying the page blob uploaded correctly by using Storage Explorer. If you see the blob and can download it from in Storage Explorer as a PDF, then you know the upload operation is good. If not, then you the issue is either with the body or not setting the content-type of the blob itself. Put Blob (REST API) - Azure Storage | Microsoft Learn doesn't mention sending the payload as JSON so I would just try uploading bytes as is and setting the content type to application/pdf.

    If you're using Postman to test with, then I would also strongly suggest utilizing one of the SDKs so you can follow the best security guidelines and Authorize access to blobs using Microsoft Entra ID - Azure Storage | Microsoft Learn.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.