Inserting Records in Account or (any other sObject) Through Postman in salesforce

Inserting Records in Account or (any other sObject) Through Postman in Salesforce

We are using postman from API testing and request management to hit API by get or post and received data in the form of JSON and XML.

We can also add a record from Postman to our Salesforce org.

We're going to use OAuth2 and the authorization code flow.

Step 1: create your connected app

  • Inside Salesforce setup, navigate to Build > Create > Apps.
  • In the bottom panel of the page, where it says Connected Apps, click New. This will open a dialog to create a new connected app.
  • In Name, type "Postman", and supply a mandatory contact email
  • Make sure Enable OAuth settings is ticked.
  • As an additional step, you need to ensure you add https://www.getpostman.com/oauth2/callback to the callback URL list (see below). This is the Postman endpoint that will receive the token.

Postman endpoint that will receive the token

Postman endpoint that will receive the token

Step2: OAuth with Postman

Postman has built-in OAuth-base authorization. In Postman, click on the Authorization tab and select "OAuth 2.0".

OAuth with Postman

Click on Get New Access Token to launch the OAuth dialog. Use the following values:

Token Name:  My Postman Token or (Any name) Auth URL: https://login.salesforce.com/services/oauth2/authorize  Access Token URL: https://login.salesforce.com/services/oauth2/token  Client ID: (the consumer key from your connected app) Client Secret: (the consumer secret from your connected app) Scope: (you can leave this empty) Grant Type: Authorization Code

Get Access Token

Click on Request Token. This will take you to the Salesforce login screen, where you can type your credentials.

Salesforce login screen

Click on Use Token and in the Add token to drop-down, select "Header", so that the token will be added to the HTTP request headers. You're now ready to call your web service.

Make the request

https://ap5.salesforce.com/services/data/v36.0/sobjects/Account/

Regarding inserting an Account in Salesforce, you have to POST a JSON request like this

{
    "Name": "From Postman in salesforce"
}

Click Send.

Get Status code 201

Get Status code 201 Created.

Get record Id.

And “Success”: true,

It will create a record in Salesforce org.

create a record in Salesforce

 

Popular Salesforce Blogs