製作出站標註

這是關於如何從 salesforce 呼叫 Web 服務的示例。下面的程式碼是呼叫 data.gov 上託管的基於 REST 的服務,以查詢靠近郵政編碼的農貿市場。

請記住,為了從你的組織呼叫 HTTP 標註,你需要調整組織的遠端設定。

string url= 'http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=10017';
Http h = new Http();
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
req.setEndpoint(url);
req.setMethod('GET');
res = h.send(req);
System.Debug('response body '+res.getBody());