Vish
Vish

Reputation: 2164

xml-rpc request using curl?

I have a Magento server that has various methods exposed through the API. I am prototyping various client-side modules to call this API. This has been successful so far.

I just started using curl to push xml through. Surprisingly, I'm unable even to get past the API login. Here's what I am doing (the 'login' method takes two strings, the username and password).

curl --data-urlencode @xmlrpc http://domain/api/xmlrpc

contents of file xmlrpc

<?xml version="1.0"?>
 <methodCall> 
 <methodName>login</methodName>
 <params>
 <param>
 <value>apiUser</value>
 </param>
 <param>
 <value>apiKey</value>
 </param>
 </params>
 </methodCall>

This is what I get:

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>631</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Failed to parse request</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>

what does that error mean?

Upvotes: 9

Views: 20962

Answers (1)

Vish
Vish

Reputation: 2164

And, as usual, my beginner-query ended up being about something simple.

curl --data @xmlrpc http://domain/api/xmlrpc

instead of

curl --data-urlencode @xmlrpc http://domain/api/xmlrpc

gave me a nice, new session variable indicating that I have been logged in!

<methodResponse><params><param><value><string>eaab9ac0780f6bc9ba867804</string></value></param></params></methodResponse>

Upvotes: 15

Related Questions