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
AbAb 

getting data from webservice link

Hello,
 
https://servicesgateway.com/{version}/rest/{service}
 <ConfigElement name="cAccount" Url="https://servicesgateway.com/1/rest/searchByName" ContractID="XXXX" UserPrefix="XXXXXXX" UserID="XXXXX" Password="XXXXX" AppID="XXX" Version="1" />

I have a above link, which is link for web service.

I want to get the data from this link.

What are steps to do so using REST 

Thanks
Best Answer chosen by Ab
Shashi PatowaryShashi Patowary
Hi Sandrine,

You can make use SFDC provided in-biult classes for calling HTTP request -

e.g.

HTTP h = new HTTP();
HTTPRequest req = new HTTPRequest();
req.setEndpoint('https://servicesgateway.com/1/rest/searchByName');
Blob header = Blob.valueOf(UserId+ ':' + Password);
String authHeader = 'BASIC ' + EncodingUtil.base64Encode(header);
req.setHeader('Authorization', authHeader);
req.setMethod('GET');
HTTPResponse resp = req.send(req);
System.debug(res.getBody());

You need to add 'https://servicesgateway.com' to remote site setting and you can parse the response using XML or JSON.

Please let me know if it heps.

Regrads,
Shashi

All Answers

Shashi PatowaryShashi Patowary
Hi Sandrine,

You can make use SFDC provided in-biult classes for calling HTTP request -

e.g.

HTTP h = new HTTP();
HTTPRequest req = new HTTPRequest();
req.setEndpoint('https://servicesgateway.com/1/rest/searchByName');
Blob header = Blob.valueOf(UserId+ ':' + Password);
String authHeader = 'BASIC ' + EncodingUtil.base64Encode(header);
req.setHeader('Authorization', authHeader);
req.setMethod('GET');
HTTPResponse resp = req.send(req);
System.debug(res.getBody());

You need to add 'https://servicesgateway.com' to remote site setting and you can parse the response using XML or JSON.

Please let me know if it heps.

Regrads,
Shashi
This was selected as the best answer
DineshGuptaDineshGupta
Hi.. Shashi Patowary..

The request should be sent by the http object as below.
HTTPResponse resp = h.send(req);

Regards,
Dinesh
Shashi PatowaryShashi Patowary
Yes Dinesh, that was a typo. I cannot modify the post.Thanks for pointing out.

Regards,
Shashi