Magento Core API
We are happy to announce the availability of Magento Core API with the release of Magento 1.1 (currently in alpha through SVN). Documentation for the API is available here. We hope you will find this useful for integrating Magento with other 3rd party solutions.






1Sprout Collective from Portland, OR / Orange County, CA|posted July 8 2008
Nice work on the documentation, we’re really excited to dive into this.
-Cliff
2Aleksander Andrijenko |posted July 8 2008
Very good! Nice work Magento team!!!
-Aleksander
3iguru from Děčín, Czech Republic|posted July 8 2008
Super!!! Nice work.
Is possible to download (etc. PDF)?
4jstrobel |posted July 8 2008
If you want to try it, i have written a little PHP-Example to call the API via SOAP:
http://weblog.pixeldreamz.com/2008/07/06/magento-und-die-api/
(Article in german)
5ptjedi |posted July 8 2008
Thank you! Awesome release!
6nicolas46 from Toulouse|posted July 8 2008
Great job !!
a pdf would be great please.
7epromer |posted July 8 2008
If someone would like to use the Api with Java:
Apache Axis has problems with the authentication. Use Apache xml-rpc and implement a TypeFactory to handle nil’s.
@Varien: Nice Job and many thanks.
8roco |posted July 8 2008
Nice work Yoav and Team!!
Is there any chance you will provide a screencast on using the API to make catalog updates?
9[m] zentrale from Stuttgart, Germany|posted July 8 2008
well done magento team! big up!
10MasterDee |posted July 8 2008
this is great Magento team, I’am more and more impressed.
11WebAddict from Chandler, AZ|posted July 8 2008
This is what I’ve been waiting for! I will finally be able to manage my thousands of products by simply using the API of my supplier, and the new Magento API. I just need to write a few simple scripts to manage it. This is great news! I can’t wait for the next release of Magento (1.1)!
12MagentoJoe |posted July 9 2008
Great! Our application is written in the rather unknown language PL/B (http://www.sunbelt-plb.com) which doesnt have either a SoapClient or an XML-RPC client, so we’ll need to do some tricks by using cURL it seems like. But great news - and I hope both the documentation and examples gets filled up by the time.
PS: It would be GREAT if you made the documentation like php.net has, where the community can submit useful code-examples, which are checked, approved and publised - below the documentation.
13RoyRubin from Los Angeles, CA|posted July 9 2008
@aFFi - The documentation is in the wiki for exactly that purpose. It is our hope that the community continues to improve and update the documents with code examples and further clarifications.
14Sprout Collective from Portland, OR / Orange County, CA|posted July 10 2008
When trying to consume the web service from .NET it errors with: “Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’. Unable ti import operation ‘multiCall’ datatype ‘Array’ is missing.
Any ideas?
15cadessi |posted July 13 2008
@Sprout Collective
That’s because the generated wsdl file is not compliant with WS-I Basic Protocol 1.1. To overcome this, edit the “wsdl.xml” file in “magento\app\code\core\Mage\Api\etc” (DO NOT forget to backup first):
Replace
<wsdl:types >
with
<wsdl:types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"
schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" >
<xsd:complexType name="FixedArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[]">
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
And then, for every <wsdl:part> that contains
xsd:arrayType="xsd:anyType" type="soapenc:Array"
remove
xsd:arrayType="xsd:anyType"
and replace
type="soapenc:Array"
with
type="typens:FixedArray"
I hope the Magento Team will solve this problem by regenerating the wsdl file with some other WS-I compliant tool.
16boardwalk from Cornwall, UK|posted July 22 2008
Hi Sprout Collective and cadessi ,
I just found this thread as I have encountered problems with the API and not being able to connect to it from .net or Visual Fox Pro.
I searched through the wsdl file and cant find any reference to <wsdl:types> . Did I miss something? Have Magento Team changed the wsdl generation or am I missing something?
Any help would be greatly received
Thanks
James
17Geraldton |posted July 26 2008
using cadessi changes finally I managed to create a .Net SOAP Proxy using WSDL.exe but calling the api gives me the following error:
Client found response content type of ‘text/html; charset=UTF-8’, but expected ‘text/xml’.
I realized that session is returned in Soap Envelop but for some reason the content type is not set to text/xml. I was wondering if any one from Magento core team can advise how this can be fixed. I can see that this is been set for WSDL template generation on line 107 in \app\code\core\Mage\Api\Model\Server\Adapter\Soap.php but not sure how to set it for the rest of Soap response calls.
Thanks,
Ron
18Magento Core from Los Angeles, CA|posted July 31 2008
@Ron: What request did you get wrong response content type on ?
19Geraldton |posted July 31 2008
Hi There,
Thanks for reply. Basically I call Magento Service to create a session using followng line of codes in .Net:
MagentoService magesvc = new MagentoService();
session = magesvc.login(apiuser, apikey);
and receive following error. As you can see SOAP envelope contains my session id but the whole response content type is set to ‘text/html’ than ‘text/xml’. I tried using fiddler 2.0 to monitor the response even using PHP client and it is ‘text/html’ but PHP does not care about it but .Net does. Looking at line 107 at app\code\core\Mage\Api\Model\Server\Adapter\Soap.php I can see that this has been set for /?wsdl response by
$this->getController()->getResponse()
->setHeader(’Content-Type’,’text/xml’)
->setBody($template->filter($wsdlContent));
but not sure how can be set for all the remaining call responses too. Here is the error I get with correct SOAP Envelope:
Client found response content type of ‘text/html; charset=UTF-8’, but expected ‘text/xml’.
The request failed with the error message:
--
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:loginResponse><loginReturn xsi:type="xsd:string">p1m9kdhu5vhl1ao3m4tc8kbhp5</loginReturn></ns1:loginResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
--.
20nroux from Clermont-Ferrand, France|posted July 31 2008
@Magento Core: When do you expect to have the wdsl compliant with WS-I Basic Protocol?
21Michael |posted July 31 2008
@nroux : What are the WS-I Basic Protocol compliance isues you got ? What client library do you use ?
22nroux from Clermont-Ferrand, France|posted July 31 2008
@Michael : I use JAX-WS included in the JDK6. I can’t use the SOAP service as rpc/encoded is not compliant. The returning error is : rpc/encoded wsdls are not supported in JAXWS 2.0. I’ve seen in previous comments that the problem exists also with .Net. The only way I have is to use XML-RPC, but using SOAP is much more convenient for many reasons.
23Geraldton |posted July 31 2008
Ok it seems I found the fix for Content type. You need to modify else block in run() function of app\code\core\Mage\Api\Model\Server\Adapter\Soap.php line 110 with following code replacing line $this->_soap->handle(); with the following code. So far I can get session id successfuly returned. Now I will be able to test SOAP CALL function.
} else {
$this->_soap = new SoapServer(Mage::getUrl(’*/*/*’, array(’wsdl’=>1)));
use_soap_error_handler(false);
$this->_soap->setClass($this->getHandler());
//$this->_soap->handle();
$this->getController()->getResponse()
->setHeader(’Content-Type’, ‘text/xml’)
->setBody($this->_soap->handle());
}
24boardwalk from Cornwall, UK|posted August 1 2008
Hi @Geraldton,
Thanks for the code that has enabled me to get the api working well I can get a session id at least, however when I then try a SOAP CALL action I get access denied, any ideas?
Thanks
James
25Geraldton |posted August 1 2008
@James,
I was strugelling with this yesterday all day and I found some temporary solution which makes your call work and that is to comment out Access denied section at line 220 in \app\code\core\Mage\Api\Model\Server\Handler\Abstract.php now I can at least get product info using:
magentoservice(session_id, “product.info”, new object[] {"sku"}) in some format but can not figure out how to create and send $newproductdata array which is a complex structure to product.create. I keep getting “There was an error generating XML Document\” Any ideas?
//if (!isset($resources->$resourceName->public)
// && isset($resources->$resourceName->acl)
// && !$this->_isAllowed((string)$resources->$resourceName->acl)) {
// return $this->_fault(’access_denied’);
//}
Thanks,
Ron
26Killoff |posted August 1 2008
@boardwalk, Geraldton
Did you create an API User and assign it a Role in Admin panel ?
27Geraldton |posted August 1 2008
@Killoff
sure with full access but still you get Access denied using .Net Client but PHP client works fine.
28svenniuwe |posted August 3 2008
does this API provide the possibility to create an order via Webservice/SOAP ?
Thanks
Sven
29Killoff |posted August 4 2008
@Geraldton
Can you view the contents of /var/session dir on the services Server?
Are session files created when you call login etc.?
30Killoff |posted August 4 2008
@svenniuwe
Unfortunately, not yet.
This method will be soon implemented. Thank you for interest
31boardwalk from Cornwall, UK|posted August 6 2008
@Killoff
Yes I created a APi user etc, and yes when I browse to the var/session there is a session file corresponding to the session ID which is returned.
I have checked it is not permissions bases and opened up the session file to 777 just in case. Still no joy, I have tried several different functions just in case it was one which had a problem.
In the log files I can’t spot anything of relivence. Is there a Soap Log somewhere?
Thanks James
32bobbrodie |posted August 6 2008
I don’t think the problem is with Magento, but with Windows.
http://support.microsoft.com/kb/925492
33Geraldton |posted August 6 2008
@bobbrodie
This is not about MSDiscoCodeGenrator, I have my C# proxy generated using WSDL.exe and I can read product.info successfully but only if I comment out Access denied part in Handler (see previous post) otherwise Magento returns Access Denied no matter what you call from windows. Looking into Soap Envelop it doesn’t seem having any issues in Windows.
Ron
34Killoff |posted August 7 2008
Please, see Api / Model / Server / Handler / Abstract.php
Access denied fault may have no one reason.
So, investigate the exact lines of code where it occurs. I think you have problems not in login() method.
35Samarendra from Kolkata|posted August 16 2008
Hi
i am getting this error when i try to use Api in .net 2.0
Error 1 Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’. App_WebReferences/WebReference/
Please help me to resolve this problem .
Thanks
36adrianhedley |posted August 17 2008
Hi,
I have upgraded to magento 1.1.3 but i still Getting the error:
Custom tool error: Unable to import WebService/Schema. Unable to import binding ‘Mage_Api_Model_Server_HandlerBinding’ from namespace ‘urn:Magento’. Unable to import operation ‘call’. The ref syntax for groups is not supported with encoded SOAP. Please change definition of schema type ‘Struct’ from namespace ‘http://schemas.xmlsoap.org/soap/encoding/’: replace the group reference with local group declaration. C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\MagentoStoreManager\MagentoStoreManager\Properties\Settings.settings
I tried both visual studio 2005 and 2008 but i get the same error either way.
Any pointers pls? I’ve spent the last 4 days looking for a solution but still nothing works
Thanks
Adrian
37frontier |posted August 22 2008
Just posting to say that I too want to call Magento web services from .NET.
Please @MagentoCore fix this in 1.1.4.
38Killoff |posted August 28 2008
The problem in our wsdl. The matter is that we use soap body encoding like this:
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
which is not compatible with WS-I Basic Profile compliance:
The Profile prohibits the use of encodings, including the SOAP encoding.
R2706 A wsdl:binding in a DESCRIPTION MUST use the value of “literal” for the use attribute in all soapbind:body, soapbind:fault, soapbind:header and soapbind:headerfault elements.
So, if it will be <soap:body namespace="urn:Magento" use="literal"> it can help.
But in this way we have another problem - data format (xml and result arrays) changed.
And we still working on this. Maybe someone knows good decision?
39Samarendra from Kolkata|posted August 28 2008
I have able to connect the Webservice from .NET, it will work fine with login and i got the SessionID
and i will get the list of product also, but i want to send the filter parameter how will send the parameter from .net
how i will build the php parameter array in .net ?
40nroux from Clermont-Ferrand, France|posted August 28 2008
@killoff
For sure, the standard API included in the latest Java JDK (https://jax-ws.dev.java.net/) can’t handle encoded body, so it would be really useful to have the basic profile respected.
41aafshar |posted October 9 2008
Still no word on the order.create API? We desperately need it.