can we query SOSL using REST API? As we can do with SOQL like this : /services/data/v37.0/query/?q=
2 Answers
Yes you can do SOSL query using REST Api.
The api would be - /services/data/v37.0/search/?q=SOSL search string
The SOSL search string needs to be URL encoded.
Here is a link for more details - SOSL Search using REST API
Here is an way how you can make a successful REST API call.
String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm();
String url = salesforceHost + '/services/data/v37.0/search/?q='+EncodingUtil.urlEncode('FIND {Joe Smith} IN Name Fields RETURNING lead', 'UTF-8'); // use your own SOSL statement
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(url);
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug('res'+res.getbody());
-
-
I did'nt find any solution of this issue.Any help would be appreciated.– oookkkFeb 15, 2017 at 9:26
Thanks all.. BUt I found solution for that also /services/data/v37.0/ParametrisedSearch/?q= isTest
-
Can you add details on this. Just one liner won't help others having same issue.– ReshmaMar 1, 2017 at 9:39