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
Post a Comment