Upload Image from Postman to Salesforce

Jan 3, 2025


 

Attaching files to Salesforce via Postman involves two key steps:

  1. Obtaining an access token.

  2. Using the POST method to upload the file.

Here’s a step-by-step guide to help you achieve this

 

Step 1: Get an Access Token

Before making API calls to Salesforce, you need an OAuth 2.0 access token.

Steps to Obtain an Access Token: Get Access Token Using Postman

 

Step 2: Upload the File Using the POST Method
Endpoint

To upload a file to Salesforce, use the ContentVersion API:

  1. Set Up the Request:

    • Method: POST

    • URL: https://<yourInstance>/services/data/v57.0/sobjects/ContentVersion/

  2. Add Headers:

    • Authorization: Bearer <Your Access Token>

    • Content-Type: application/json

  3. Add the Body (as raw JSON):

    {
    "Title": "Salesforce Test Image",
    "PathOnClient": "Salesforce.PNG",
    "ContentLocation": "S",
    "OwnerId": "<OwnerId>",
    "VersionData": "<Blob of the image>"
    }
  1. Send the Request:

    • Click Send in Postman.

    • If successful, Salesforce will return a JSON response with details about the uploaded file, including the ContentDocumentId. 

 

 

 Step 3: Verify the File in Salesforce

After uploading, you can verify the file:

  1. Navigate to the Files tab in Salesforce.

  2. Search for the file we just created with title name.

  3. Confirm that the file has been uploaded and is accessible.