+ Start a Discussion
Sirisha NSirisha N 

no viable alternative at character '"' errorCode: MALFORMED_QUERY when passing value in the WHERE clause in the REST API URL

I tried executing the following Rest API on the Salesforce workbench -
in REST Explorer

/services/data/v48.0/query/?q=SELECT+Total_Cost__c+from+DBA_Invoice__c+where+Name="I-525"

I get the following response-

MALFORMED_QUERY
message: from DBA_Invoice__c where Name="I-525" ^ ERROR at Row:1:Column:52 line 1:52 no viable alternative at character '"'
errorCode: MALFORMED_QUERY

However, it works without the where clause. 

Could you please tell me how do specify the value in the where clause?
Best Answer chosen by Sirisha N
David Zhu 🔥David Zhu 🔥
You have to use single quotation mark in where clause.
/services/data/v48.0/query/?q=SELECT+Total_Cost__c+from+DBA_Invoice__c+where+Name='I-525'

All Answers

David Zhu 🔥David Zhu 🔥
You have to use single quotation mark in where clause.
/services/data/v48.0/query/?q=SELECT+Total_Cost__c+from+DBA_Invoice__c+where+Name='I-525'
This was selected as the best answer
Sirisha NSirisha N
Thank you David. This worked for me.