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
Sirisha NSirisha N 

How to retrieve a custom object based on a custom field using Rest API?

Hi,

I tried using /services/data/v48.0/sobjects/DBA_Invoice__c?Invoice_No__c=I-52555
But this retrieves all records.
ShirishaShirisha (Salesforce Developers) 
Hi Sirisha,

Greetings!

If you would like to query based on the field value then you would need to use the Query as it search for field value and then give you the list of records.

Example:/services/data/v41.0/query/?q=SELECT+Id+from+DBA_Invoice__c+where+Invoice_No__c=I-52555

Reference:https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_query.htm

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Sirisha NSirisha N
Shirisha, I tried that and it says MALFORMED_QUERY-

Raw Response
HTTP/1.1 400 Bad Request Date: Thu, 20 Aug 2020 12:16:55 GMT Strict-Transport-Security: max-age=31536000; includeSubDomains Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJvNEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hpkp-report/nullm"; Expect-CT: max-age=86400, report-uri="https://a.forcesslreports.com/Expect-CT-report/nullm" X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Robots-Tag: none X-B3-TraceId: 748deaed865ada13 X-B3-SpanId: 748deaed865ada13 X-B3-Sampled: 0 Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private Set-Cookie: BrowserId=CVx1J-LfEeqrLeWYRpK2Hg; domain=.salesforce.com; path=/; expires=Fri, 20-Aug-2021 12:16:55 GMT; Max-Age=31536000 Sforce-Limit-Info: api-usage=321/15000 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked
[ { "message" : "\nDBA_Invoice__c where Invoice_No__c=I-52555\n ^\nERROR at Row:1:Column:60\nBind variables only allowed in Apex code", "errorCode" : "MALFORMED_QUERY" } ]
ShirishaShirisha (Salesforce Developers) 
Hi,

Can you please try the below request if the value of the field is as "I-52555"

/services/data/v41.0/query/?q=SELECT+Id+from+DBA_Invoice__c+where+Invoice_No__c="I-52555"

Thank you!
 
Sirisha NSirisha N
It worked with single quotes.