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?
XML-RPC requests are a combination of XML content and HTTP headers. The XML content uses the data typing structure to pass parameters and contains additional information identifying which procedure is being called, while the HTTP headers provide a wrapper for passing the request over the Web.
The request itself is a specially formatted XML document. As a client, you build up an XML request to send that fits with the XML-RPC specification. You then send it to the server, and the server replies with an XML document. You then parse the XML to find the results.
XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.
XML-RPC is a feature of WordPress that enables data to be transmitted, with HTTP acting as the transport mechanism and XML as the encoding mechanism. Since WordPress isn't a self-enclosed system and occasionally needs to communicate with other systems, this was sought to handle that job.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With