Happy Business Starts Here

Highlighted
Support SME

How to query records containing single quote characters via SOAP API?

Question:

 

How to query records where the single quote character has been used in object names, e.g. a Customer called Bob's Burgers?



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

1 REPLY 1
Support SME

Re: How to query records containing single quote characters via SOAP API?

Answer:

 

The backslash \ escape character needs to be used in your SOAP query.

 

This format will work, note the \ before the single quote in the "name" field:

 

 

SELECT id FROM account WHERE name='Bob\'s Burgers'
 
<ns1:result>
<ns1:done>true</ns1:done>
<ns1:queryLocator xsi:nil="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<ns1:records xsi:type="ns2:Account" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:Id>2c92c0f8589a05e201589cb4b21f654a</ns2:Id>
</ns1:records>
<ns1:records xsi:type="ns2:Account" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:Id>2c92c0f9589a1c7401589cb642821f32</ns2:Id>
</ns1:records>
<ns1:size>2</ns1:size>
</ns1:result>

 

This format would fail:

 

SELECT id FROM account WHERE name='Bob's Burgers'
 
<faultcode>fns:MALFORMED_QUERY</faultcode>
<faultstring>You have an error in your ZOQL syntax</faultstring>
<detail>
<fns:MalformedQueryFault>
<fns:FaultCode>MALFORMED_QUERY</fns:FaultCode>
<fns:FaultMessage>You have an error in your ZOQL syntax</fns:FaultMessage>
</fns:MalformedQueryFault>
</detail>
</soapenv:Fault>

 



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √