Skip to main content

Salesforce REST API III

After receiving the access token we will be able make requests and get data from salesforce via the rest api.

When we making a request we need  to add Authorization header in each and every request that including the access token. If the access token is missing , invalid or expired we will get 401 Unauthorized error.Header value should be like below.There should be a space between OAuth and access token.

                      Authorization  OAuth  access_token.

Salesforce rest api has a service ( one of my favorite service ) to make queries through the request. So we will make a select query get all the accounts in salesforce.

Sample service :   https://login.salesforce.com/services/data/v34.0/query?q='you query goes to here'

Now I'm going to get all accounts in salesforce by using 'SELECT Id , Name FROM Account LIMIT 10' query. Here getting only 10 records because of the salesforce governor limit.

therefore I need to send  below get request with the Authorization header

https://login.salesforce.com/services/data/v34.0/query?q=select+Id+,name+from+account+limit+10 



Below screen you can see the related post man request.
























So you will be able to do lots of things through the rest api. If you need to make pagination , salesforce supports for the offset keyword to return data with the  pagination. refer below link for that.
https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_offset.htm

You will be able to do crud operations and many more with the rest api and it's light weight and easy to use.

Please send me your suggestions , comments and any clarification on this.

Thanks,
Prasad





Comments

Popular posts from this blog

Exploring the Marvels of Salesforce Marketing Cloud: Unleashing the Power of Marketing Automations

Salesforce Marketing Cloud is a comprehensive marketing automation platform offered by Salesforce, a leading customer relationship management (CRM) company. It is designed to help businesses manage and optimize their marketing efforts across various channels and touchpoints. The platform enables organizations to create, execute, and analyze marketing campaigns to engage with their target audiences more effectively and drive better results. Key features and capabilities of Salesforce Marketing Cloud include: Email Marketing: Users can create and send personalized email campaigns to segmented audiences, track email performance metrics, and automate email workflows to nurture leads and build customer relationships. Journey Builder: This tool allows marketers to design and automate customer journeys across multiple channels such as email, mobile, social media, and advertising. It helps create personalized experiences based on customer behavior and interactions. Social Media Marketing: Sale...

Integrate .NET console application with Salesforce Rest API

According to the integration perspective in Salesforce there are several APIs to integrate with external systems. As an example there are REST API, SOAP API, Bulk API, Tooling API and Streaming API. Here I will focusing for Rest API. I have created a different post which will describing the integration with Salesforce Soap API. You can find it from  here . And for the Tooling API you can find it from  here . 1st of all you need to create a connected app in Salesforce in order to make the bridge to integrate with console app.  A connected app integrates an external application with Salesforce using APIs. Connected apps use standard SAML and OAuth protocols to authenticate, provide single sign-on, and provide tokens for use with Salesforce APIs. So I have created a separate post which will describe how to create a connected app to get consumer id and consumer secret. Please follow  this   post to get consumer id and consumer secret. After you...

How to automate testing using Selenium and C#

Hi All, today I’m going to explain about Selenium which is a open source automation tool and how to utilize it with C#. As you know automation tools save our time in terms of testing a software product. If we are doing some regression testings automation tools doing a great job in terms of saving the time. So I’m going to explain a very simple example for using Selenium from C#. We can divide selenium as two entities. One is Selenium IDE as a web browser extension. And the other one is Selenium Web Driver. So I’m going to talk about the selenium web driver which is using for web based testings from C# code. Basically Selenium Web driver will open the browser and doing the actions as we instructing in the C#code. Firstly you need to install visual studio. For my case I have installed visual studio community version which is a free version of Microsoft. Then you need to create a project by navigating to File -> New -> Project. And give a name for the project and click ok...