xml-rpc request using curl?

匿名 (未验证) 提交于 2019-12-03 08:41:19

问题:

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?

回答1:

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> 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!