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

How to integrate Salesforce streaming api with .NET Core application

This post has been written for the developers who are looking to fulfill the knowledge gap of the .NET core and Salesforce integration via streaming and rest api. So today I'm going to explain about the integration of .NET core console application and Salesforce streaming api which is using CometD event bus. .NET Core is a open source and cross platform implementation of the .net framework. It is maintained by Microsoft and the .net core has vast community of developers over on GitHub. What is Salesforce Streaming API ? Streaming API has publisher/subscriber model which enables streaming of events using push technology and provides a subscription mechanism for receiving events in real time. The Streaming API supports multiple types of events. Below I mentioned the event types. PushTopic events Generic events Platform events Change Data Capture events. Streaming Event features comparison which I taken from here . Push Topic Event as publish / subscribe model. If we ...

Salesforce Tooling Api

Hello Eveyone, Today I'll be focusing on Salesforce Tooling API and explaining how to integrate with a .NET console application. Here I'm using console application because I need to keep it simple. Tooling Api is available for SOAP and REST. In this post I'm focusing on SOAP  which will be creating an apex class from the api. What can do from Salesforce Tooling API Deploy Apex, Triggers and Visualforce Pages Manage validation rules, static resources, workflow rules Manage custom fields on custom objects Execute tests synchronously or asynchronously Org wide and class specific code coverage Execute anonymous Apex Access debug logs Tooling API is specifically designed to help developers build IDE apps for Salesforce, while the metadata API is more general purpose configuration migration. Tooling API will support for wide range of objects and you can find the list of objects from here . Tooling API vs Metada API Technically, the Tooling API could completely re...

Salesforce REST API

This post describe about the salesforce rest api and using salesforce rest api . Salesforce implements the OAuth to authenticate soap and rest calls with the client. So I will describe with the simple steps, how to create salesforce app that expose outside to authenticate and call rest methods. First you need to create a salesforce developer account if you don't have an developer account or sandbox account. If you don't have an developer account go with the following link and create an account. It's free.   https://developer.salesforce.com/signup . Once you create the developer account go to https://login.salesforce.com/ and login with your credentials.     Navigate to setup and type app and you will be able to find Apps section and click the link. So now you will be able to find Connected Apps section and click New. What we doing here is creating a connected app and that app will exposing to outside to authenticate and call rest api calls. So you ...