0

I am calling salesforce api using two queries which I mentioned below. For first query I am getting 200 status code with response and for second query I am getting 400. I searched a lot on internet but didn't get anything..Am I missing something in that query??

First Query::

https://abc-client.salesforce.com/services/data/v39.0/query?q=Select+id+from+Account+where+Name+like+'%Keysto%'+and+BillingPostalcode+=+'FY1 3PB'

Output:: 200 status code


Second Query:: https://abc-client.salesforce.com/services/data/v39.0/query?q=Select+id+from+Account+where+Name+like+'%R Cart%'+and+BillingPostalcode+=+'PE23 5DW'

Output:: 400 status code

  • 1
    URI encode the query in python. https://stackoverflow.com/questions/46783078/uri-encoding-in-python-requests-package – identigral Sep 09 '20 at 19:07
  • Have you tried to run both query in the query editor (in dev console) ? Just to check that Salesforce can process them internally. – Bartheleway Sep 11 '20 at 08:43

1 Answers1

0

400 is usually a Bad Request Error that arises from incorrect URL. Be sure to URI encode your query before appending to the URL. In case of js, you can use

encodeURIComponent(your_query_string_here)

and use it as follows.

'https://abc-client.salesforce.com/services/data/v39.0/query?q='+encodeURIComponent(your_query_string_here)
Bonish Koirala
  • 641
  • 5
  • 16