function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vinni shreevinni shree 

How to get data from REST API and Store data in salesforce or apex class

Hi,

Using postman I made a rest api call and now I have a requirement to show that data in a screen in salesforce. So how do I store that data in salesforce.

Thank you

Best Answer chosen by vinni shree
SubratSubrat (Salesforce Developers) 
Hello Vinni ,

To store the data from your REST API call in Salesforce, you can use Apex to create a custom object and insert records into it. Here are the general steps to achieve this:

1) Create a custom object in Salesforce that corresponds to the data you received from your REST API call. Make sure to add necessary fields.

2) Write an Apex class that uses the HTTP callout to retrieve data from the REST API and then parse the response. (https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_rest_callouts?tb_cmp=growth_paid_search&gclid=Cj0KCQiA6fafBhC1ARIsAIJjL8lg5JdpSx74ZzwuREsvTPZlUSqIIGFGBpv0bLDgR2PA37wKXx7KPfoaArb2EALw_wcB&gclsrc=aw.ds

3) In the Apex class, create new instances of the custom object and populate the fields with the data retrieved from the REST API.

https://bullhorn.github.io/Custom-Objects/ )

Use the DML (Data Manipulation Language) statements in Apex to insert the records into the custom object.

Optionally, create a Visualforce page or a Lightning component to display the data in Salesforce.

Please refer -> https://www.mstsolutions.com/technical/apex-callouts-to-display-external-data-in-salesforce/

For VF page .


If the above information helps , please mark this as Best Answer.
Thank you.

All Answers

SubratSubrat (Salesforce Developers) 
Hello Vinni ,

Can you specify the Request type like whether it is POST , GET .
Or what exactly is the need .

For your query I have came across a Help article . Requesting you to go through it and let me know further -> https://hevodata.com/learn/salesforce-rest-api-postman/


Hope it helps !
Thank you.
vinni shreevinni shree

Hello Subrat 

Request Type is Post.
 

Thank you

SubratSubrat (Salesforce Developers) 
Hello Vinni ,

To store the data from your REST API call in Salesforce, you can use Apex to create a custom object and insert records into it. Here are the general steps to achieve this:

1) Create a custom object in Salesforce that corresponds to the data you received from your REST API call. Make sure to add necessary fields.

2) Write an Apex class that uses the HTTP callout to retrieve data from the REST API and then parse the response. (https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_rest_callouts?tb_cmp=growth_paid_search&gclid=Cj0KCQiA6fafBhC1ARIsAIJjL8lg5JdpSx74ZzwuREsvTPZlUSqIIGFGBpv0bLDgR2PA37wKXx7KPfoaArb2EALw_wcB&gclsrc=aw.ds

3) In the Apex class, create new instances of the custom object and populate the fields with the data retrieved from the REST API.

https://bullhorn.github.io/Custom-Objects/ )

Use the DML (Data Manipulation Language) statements in Apex to insert the records into the custom object.

Optionally, create a Visualforce page or a Lightning component to display the data in Salesforce.

Please refer -> https://www.mstsolutions.com/technical/apex-callouts-to-display-external-data-in-salesforce/

For VF page .


If the above information helps , please mark this as Best Answer.
Thank you.
This was selected as the best answer
vinni shreevinni shree
Thank you Subrat. This is very understandable.