Getting record details from Salesforce using the Rest API

This article explains how to connect to Salesforce using Postman to perform integration tests then retrieve record details from Salesforce.

Salesforce provides a Connected App to connect with the platform with any other application.

Getting started with Salesforce Manage Connected App

First, log in to Salesforce org and go to Setup then click on App manager


Click on New Connected App Button in the section.

Then you will see the page below

    1. Give the Name of the Application.
    2. Enter Contact Email and any additional information suitable for your application.
    3. Enable OAuth settings in API section.
    4. Enter a Callback URL. This is the URL that a user’s browser is redirected to after successful authentication. In this case we give https://login.salesforce.com/services/oauth2/callback as callback URL.
    5. Add Selected OAuth Scopes. For instance, Full access(full).

Click on Save button and after Click on Continue

You will be redirected to your Manage Connected App’s Page

After creating the Connected App, go and Click to reveal a link to get Consumer secret. Make a note of Consumer Key and Consumer Secret, as you need these details to authenticate the external application.

Then navigate to Manage and go to OAuth Policies section select IP restrictions as Relax IP restrictions.

Now we will see how to call and integrate Salesforce with Postman.

Postman is an application for interacting with HTTP APIs. It has powerful testing features and user GUI for making requests and reading responses.

Getting started with Postman

Install Postman by going to Postman APPs . 

Integrating Salesforce using REST API

A) Setup the HTTP login request URL

We are going to set request URL by (Base URL + Parameters), see below the structure to construct request URL for Salesforce org

https://login.salesforce.com/services/oauth2/token?grant_type=password&client_id=ConsumerKey&client_secret=ConsumerSecret&username=SalesforceUserName&password=SalesforcePassword

ConsumerKey: Consumer Key obtained from Manage Connected App. ConsumerSecret: Consumer Secret obtained from Manage Connected App. SalesforceUserName: Salesforce User ID. •SalesforcePassword: Provide the login credentials of Salesforce

B) Authenticating your request with Salesforce

Create a POST method and Copy the request URL as shown below and click on send.

Here we got Instance-URL, Access token, Token-type. This Access token will be used as a parameter value in Header to send any HTTP requests and get the response from Salesforce.

Retrieving record details from Salesforce

Now we will see how to get details of a record from Salesforce object using the GET.  Use this URL.

https://instance_url/services/data/v25.0/sobjects/Objectname/Id

Note

a.Instance_urlInstance_url obtained in the same manner.

b.Object NameAs Account, Contact …

c. IdId of the SObject that you have selected.

To create a GET method, copy the URL and copy the Access token along with Token type in Header section as shown below

After Click on the send button. You will get all the Account details of that particular record as shown the picture below.

I hope you find this article useful. See you soon.

Cornelia

Installed package

How to interact with Salesforce Marketing Cloud API by creating an Installed package. Let’s get started

1.First log in to Marketing Cloud and go to Setup (to be found under your username, as per the image below)

2. Under Platform tools, expand the Apps section and click on Installed Packages, then click on New.

3. Name the package, enter the Description and Save

4.  You will see the Package Details below after the package is saved. Then click on Add Component.

5. Select a Component Type. For our interacting purposes, select API Integration.

6.Select Server to Server and click on Next

7. Click on Add component and set up the package permissions

8. Select just the permissions you need according to your use case to perform the REST API call.

For more details about permissions check out this https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/rest-permissions-and-scopes.htm

In your case you will use this permission:

For interacting purposes, we choose Read access for “Documents and Images, Audiences, List and Subscriber, Email and Data Extension” then click on “save”.

After saving, you will see the page below

Note: Client Id and Client Secret are the keys to access your Marketing Cloud, you should store them securely. Never put them public on the client-side.

Once this is done, you have all information your need to get the token which enables to interact with Marketing Cloud and other systems using RESP API. You can do a test call by using your preferred developer tool such as Postman tool.

I wish you a better year!

Live with pleasure 😊

Cornelia