+ Start a Discussion
karnadesaikarnadesai 

Query Rest API having list data

Hello everyone,

 

I am having a basic trouble for Quering REST API having list data

 

Following query works,

 

SELECT Id,Name from Opportunity where AccountId='001i0000007BagvAAC'

 

I want to search not just for One records as used above but for a list of records 

 

I know in APEX we can use WHERE IN clause for the SOQL query but I am unable to replicate that with REST API.

 

I used following query's without any success

SELECT Id,Name from Opportunity where AccountId In '001i0000007BagvAAC,001i0000007BagvAAF'

SELECT Id,Name from Opportunity where AccountId In {'001i0000007BagvAAC,001i0000007BagvAAF'}

 

Please help.

kevin lamkevin lam

Have you tried this?

 

SELECT Id,Name from Opportunity where AccountId In ('001i0000007BagvAAC','001i0000007BagvAAF')

karnadesaikarnadesai

I am getting following error unexpected token: '('","errorCode":"MALFORMED_QUERY"}

Ankit Gupta@ DeveloperAnkit Gupta@ Developer

Hi,

In Rest api you have to encode the ‘single quote and ,comma with url code equivalent.

 

Try the below soql query as a reference:

SELECT%20Id%2CName%20from%20Opportunity%20where%20AccountId%20In%20(%27001i0000007BagvAAC%27%2C%27001i0000007BagvAAF%27)

%27=' single qoute

%2c=,comma