Magento Forum

Page 1 of 2
Magento API - More examples on XML-RPC
 
Roy Andre
Sr. Member
 
Avatar
Total Posts:  209
Joined:  2007-08-31
 

Great news that the API-documentation has been released. We are trying to integrate Magento using XML-RPC as we dont have any SoapClient available in our programming-language, but we’d really like to see some more examples on using XML-RPC.

Has anyone tested XML-RPC with Magento and got some examples to share? From “LoginResponse” to “ShowResources” to the Results themselves.

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
egabbud
Jr. Member
 
Total Posts:  10
Joined:  2008-07-16
 

Here are the steps I followed to make it work:

1. Install Magento 1.1 (minimum)
2. In the admin, under System -> Web Services, add one user, add one role (specify the access level for the role, or check “All"), and assign the user to the role
3. Using a XML RPC client (a good one for Mac OS X: http://ditchnet.org/xmlrpc/), set the endpoint URL to http://yourstore/magento/api/xmlrpc/
4. First call the method “login”, with 2 parameters: the user and the key (you just created them at step 2.). Refer to the screenshot in attachement.
5. The request looks like this:

<methodCall>
  <
methodName>
     
login    
  
</methodName>
  <
params>
     <
param>
       <
value>
         <
string>
           
test    
         
</string>
       </
value>
     </
param>
    <
param>
     <
value>
      <
string>
       
123456    
      
</string>
     </
value>
    </
param>
  </
params>
</
methodCall>
6. The respons looks like this (it contains your session id):
<methodResponse>
  <
params>
   <
param>
     <
value>
      <
string>
        
a10915086ca235bcf71f66cfe70bd198    
     
</string>
   </
value>
  </
param>
 </
params>
</
methodResponse>
7. Using the session id you are now able to call any other method. For example catalog_category.tree. So you just always call the method “call” and pass the 2 parameters: session id, method name (refer to screenshots in attachement). You may have other parameters to pass depending on the target method.
Image Attachments
loginRequest.pngloginResponse.pngcategoryResponse.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
Raphaël Valyi
Jr. Member
 
Total Posts:  4
Joined:  2008-07-23
 

Hi egabbud,

I downloaded the Magento 1.1.1 version and tried exactly what you told (and what the new doc says). But unfortunately, it looks like the XML/RPC server isn’t found. I’m getting a 404 HTTP error both from my Firefox browser or my Python xmlrpclib client. Same error occurs on my colleague Magento 1.1.1 fresh install too.

I’ve got Magento installed at: http://localhost/magento and the URL I’m using for my XML/RPC client is http://localhost/magento/api/xmlrpc/

Also notice that I’m getting a 404 error as well when browsing http://localhost/magento/api/?wsdl

Is there some hack I should do to get the standard XML/RPC server working?

Also please consider this is important, we just released a Magento extension to connect Magento to the famous OpenERP ERP but we used the crappy xmlrpc.inc wich seems really targeted for PHP 4 because you released your API documentation only very recently. So we would be API to use the native Magento API instead (tracker here: http://code.google.com/p/magento-openerp-smile-synchro/issues/detail?id=3 )

Best regards,

Raphaël Valyi.
Smile.fr

 
Magento Community Magento Community
Magento Community
Magento Community
 
AndreusPT
Jr. Member
 
Total Posts:  15
Joined:  2008-07-25
 

does this work?
http://localhost/magento/index.php/api/xmlrpc/
http://localhost/magento/index.php/api/?wsdl

 
Magento Community Magento Community
Magento Community
Magento Community
 
Raphaël Valyi
Jr. Member
 
Total Posts:  4
Joined:  2008-07-23
 

Hi AndreusPT,

Yeah, thanks that works!!

So I suggest the Magento team update their doc to reflect that URL change. Thank you again.
So yeah, we’ll hopefully irmprove our connector module very soon.

Raphaël Valyi
Smile.fr

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magentourist
Member
 
Total Posts:  48
Joined:  2008-08-11
Berlin
 

When looking at the API doc e.g. customer.create it says in the parameter array (country, zip, city, etc...) but where do I find the exact listing of paramters and their order?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rolf Bachmann
Jr. Member
 
Total Posts:  7
Joined:  2007-12-20
 

hi I’v tried the latest api xmlrpc without success. could anyone out ther give me a hint how to make a proper login with the tool “xml-rpc-client”?

I always get the same error.

<methodCall>
<
methodName>
login    
</methodName>
<
params>
<
param>
<
value>
<
string>
dqsw    
</string>
</
value>
</
param>
<
param>
<
value>
<
string>
dq1234    
</string>
</
value>
</
param>
</
params>
</
methodCall>

Error

<methodResponse>
<
fault>
<
value>
<
struct>
<
member>
<
name>
faultCode    
</name>
<
value>
<
int>
623    
</int>
</
value>
</
member>
<
member>
<
name>
faultString    
</name>
<
value>
<
string>
Calling parameters do not match signature    
</string>
</
value>
</
member>
</
struct>
</
value>
</
fault>
</
methodResponse>

in the shop an api user with role and so on exist.

any tip
thanks rolf

 
Magento Community Magento Community
Magento Community
Magento Community
 
Brady
Guru
 
Avatar
Total Posts:  330
Joined:  2007-09-10
Orange County, CA
 

I get the same errors as roefe - fault code 623 and “Calling parameters do not match signature”. Probably something has changed in the recent Magento releases that keep this from working.

 
Magento Community Magento Community
Magento Community
Magento Community
 
webhank
Jr. Member
 
Total Posts:  19
Joined:  2008-07-17
 

when i try to login using the information above XML-RPC client seems to work just fine - i put in my login information hit execute and it tells me that it was executed in .75 seconds - but i get nothing in the XML Response tab - i have checked my server error logs and there is nothing there either.  Can someone please shed some light on this situation?

 
Magento Community Magento Community
Magento Community
Magento Community
 
ashish96
Member
 
Avatar
Total Posts:  63
Joined:  2009-01-21
Gujarat, India
 

i m doing this way
/localhost/magento_3/api/xmlrpc/
but it shows me error below
faultCode631faultStringFailed to parse request
anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
bjorn
Jr. Member
 
Total Posts:  2
Joined:  2007-09-01
 

If you format the request as noted above it will work. I got this to work with Magento ver. 1.2.1.2 just now.

- bjorn

 
Magento Community Magento Community
Magento Community
Magento Community
 
anisrehan
Jr. Member
 
Total Posts:  9
Joined:  2008-12-01
Karachi, Pakistan
 

I am also trying the magento’s xml-rpc api.
However the situation is quite different.
I am implementing it on a php4.4 server, this means running magento on cgi-bin library.
The other trouble is magento is running alongside dolphin and I am required to run them together.

Cut the long story short, I have used xmlrpc for php (http://sourceforge.net/projects/phpxmlrpc/) and after some trial and error succeeded in adding a customer using xml-rpc call and can see the customer record in admin section.
However, that customer is not able to login saying

‘Invalid login or password.’

And when I clicked the forget your password link and entered the email address, magento replies

‘This email address was not found in our records’.

This means that, either the created record is not functional, or it is in wrong data type.

Image Attachments
'Magento Commerce' - index_php_customer_account_forgotpassword.jpg
 
Magento Community Magento Community
Magento Community
Magento Community
 
flowstack
Sr. Member
 
Avatar
Total Posts:  159
Joined:  2008-01-30
London, United Kingdom
 

I’m having the same login issue (error 623). Anyone got any further yet?

 
Magento Community Magento Community
Magento Community
Magento Community
 
robertbanh
Jr. Member
 
Total Posts:  20
Joined:  2009-03-31
 

It seems certain xmlrpc client has conversion problems between native php types, such as strings, and zend’s types.

Open up /lib/Zend/XmlRpc/Server.php in your magento folder and comment out this line:

throw new Zend_XmlRpc_Server_Exception(’Calling parameters do not match signature’, 623);

It should work after that.

 
Magento Community Magento Community
Magento Community
Magento Community
 
socalstyle
Jr. Member
 
Total Posts:  17
Joined:  2010-03-05
 
robertbanh - 23 August 2009 07:10 AM

It seems certain xmlrpc client has conversion problems between native php types, such as strings, and zend’s types.

Open up /lib/Zend/XmlRpc/Server.php in your magento folder and comment out this line:

throw new Zend_XmlRpc_Server_Exception(’Calling parameters do not match signature’, 623);

It should work after that.

So Im having same problem, I just followed your instructions and it got past that problem, but now I get -

Fatal error: Uncaught exception ‘Zend_XmlRpc_Client_FaultException’ with message ‘Access denied.’

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
robertbanh
Jr. Member
 
Total Posts:  20
Joined:  2009-03-31
 

I think that means your API username/passwd is incorrect… or your API permissions and roles don’t allow you to perform that method.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2