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
sankalita chatterjeesankalita chatterjee 

SODA API with Apex?

Hi ... Anyone has some idea about how to use SODA API along with Apex? I need to call a web service from my salesforce org. The web service exposes via the SODA API (Socrata Open Data API) however I have not found yet anything on the SODA site that says how to access via Apex. They have APIs for Java, Ruby, etc...
I have the endpoint url of the resource I need to access. Anyone can help?
James LoghryJames Loghry
Taking a quick gander at the SOAP API, they have RESTful endpoints you can call.  So although they don't have a Salesforce/APEX library for you to use, you can write your own callouts using REST to communicate with the SODA api.

More info here: http://dev.socrata.com/docs/endpoints.html
And for a quick example of performing a REST callout using the HTTP classes in Salesforce, see this SSE post: http://salesforce.stackexchange.com/questions/25852/calling-an-external-rest-service-in-apex
sankalita chatterjeesankalita chatterjee
 Hi James,

Thanks for your reply! Managed to do that with this simple code ...

HttpRequest req = new HttpRequest();
req.setEndpoint(<the endpoint>);
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);

Regards
Sankalita