can we query SOSL using REST API? As we can do with SOQL like this : /services/data/v37.0/query/?q=


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.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());

Http http = new Http();

HTTPResponse res = http.send(req);

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.
    – Reshma
    Mar 1 '17 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.