+ Start a Discussion

Restful services



I am trying to extract a data from our org based web service and updating that inform on salesforce account object.


I am using shell script to do this task

1 - Using curl command its connecting to org based web service and fetching data using standard apis.

2 - doing some data formating and generating JSON format file

3 - using this JSON file to update salesforce fields, again using curl command to update those fields.


For step 3, i have written a @RestReource class and @HTTPPost based function. All is working fine.


But I want to know, can I convert step 1 "which is currently using curl command to access web services api" to some classes in salesforce ? How can I achieve that? It will help if you give some example links, pdf etc. I saw topics about HTTP callouts but didn't get it and how am I going to achieve this?





You can call a webservice function in other Apex Code directly (i.e. it's a regular function). If you're calling an external service, it's basically the same as XMLHttpRequest in JavaScript, except it's not asynchronous. What part don't you get about making callouts?

Hi Sfdcfox,


The step 1 - I am talking about.


Can I achieve it using objects http, httprequest & httpresponse. I found an example in apex guide as "Sample: Parsing a JSON Response from a Web Service Callout".


Please let me know if you need more details. It will help to find answer.


Thanks a lot,




If I understand your question, you should indeed be able to translate steps 1 and 2 into viable Apex Code. You can generate a stripped down Enterprise WSDL and import it directly as classes, or you could write the code directly, if it suits your fancy. I'm not sure where you're trying to query the data from, though, so it's entirely possible you don't need to use rest services.