XML-RPC data service query by shipping address

Hello. How can I query the shipping address using XML-RPC and PHP? I have tried using Data Service query in a bunch of different ways, to no avail. At present, I am trying to find records that only match the shipping city, using the following code in the call, but nothing is ever returned when I try using City, City2, or City3. I’m positive the value I’m searching for is in the contacts, but I can never get results from the query. What to do?

<methodCall> <methodName>DataService.query</methodName> <params> <param> <value><string>{$key}</string></value> </param> <param> <value><string>Contact</string></value> </param> <param> <value><int>100</int></value> </param> <param> <value><int>0</int></value> </param> <param> <value><struct> <member><name>City3</name> <value><string>{$tcity}</string></value> </member> </struct></value> </param> <param> <value><array> <data> <value><string>ContactId</string></value> </data> </array></value> </param> <param> <value><string>ContactId</string></value> </param> <param> <value><boolean>0</boolean></value> </param> </params> </methodCall>

Hi Heather,

Have you consider using the SDK it would make it easier for you? :grinning:

The issue is that the Order By field is set to “ContactId” whereas it should be “Id”.

Note, if you add this line into the script: “curl_setopt($ch, CURLOPT_HEADER, true);”, you will get the Header back which will tell you failures. But then the Simple XML code will trigger an issue, so you need to extract the XML part from the response.

The updated XML code.

<methodCall> 
    <methodName>DataService.query</methodName> 
        <params> 
            <param> <value><string>{$key}</string></value> </param> 
            <param> <value><string>Contact</string></value> </param> 
            <param> <value><int>100</int></value> </param> 
            <param> <value><int>0</int></value> </param> 
            <param> <value><struct> <member><name>City3</name> <value><string>{$tcity}</string></value> </member> </struct></value> </param> 
            <param> <value><array> <data> <value><string>ContactId</string></value> </data> </array></value> </param> 
            <param> <value><string>Id</string></value> </param> 
            <param> <value><boolean>0</boolean></value> </param> 
    </params> 
</methodCall>

Hahah! I would love to use the SDK. But I’ve wasted over 10 hours trying to make it work, so …

This lookup still isn’t working. I can’t seem to make any type of lookup on the Contact table with any field. I don’t understand what I’m doing wrong. I seem to recall seeing a post in here which was saying something about the field names not matching up when using XML-RPC. Is that true?

Is there a way to use Postman with XML-RPC?

Add this line into your code to see what Header is returned, it should say the Error message.

As you can probably tell, I’m a newbie at this stuff.

I did the header thing and the status code was 200. Then I printed the raw output and saw an error in there that there is no field ContactId. So I fixed that. Whew! Slow but steady progress.

Thank you so much for all of your help, I really appreciate it!

1 Like

I am glad it worked out for you.

The SDK would have saved you a chunk of time, but unfortunately you ran into complications with it.

Using the raw XML with the Legacy API Encrypted Key is the most basic you can get with the integration.