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 from Porto, Portugal|posted July 8 2008
Thank you! Awesome release!
6nicolas46 from Toulouse|posted July 8 2008
Great job !!
a pdf would be great please.
7epromer from Germany, Schiffweiler|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)!
12Roy Andre |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.
42peysche |posted January 25 2009
Hi *
Are there any news on this Topic, the ioncombatibility still exists in 1.2.0.3
Peysche
43YoavKutner |posted January 25 2009
@peysche - this is in the works right now and we will announce the release date when it becomes current
44peysche |posted January 26 2009
Hi YoavKutner,
Thx for quick reply.
Is there a tricky (dirty) way to workaround at this time, i am an c# coder and i do not like to learn PHP or Perl :-( ?
THX
Peysche
45Euklid from Denmark|posted January 31 2009
Woha...! Thought i were the only one with WSDL C#/.NET Issues… A fix is highly appreciated.
- A Dirty quickie workaround would also be higly appreciated
46peysche |posted February 1 2009
hi *
i have tried to use the XML-RPC Interface it works if you use the open Source XML-RPC.Net Lib, but you have to mod one methode, because Magento is delivering some non standart <nil > values (Null) and the lib can not handle this info.
In any case SOAP or XML-RPC is using the sam methodes and so you can switch to SOAP if it is working without many changes in your code.
give me some infor over the boart if you want to know what must e changet ind the XML-RPC Lib.
Peysche
PS: SOAP must be fixed in any case, and it will be fine if we can use some Objects and not an genneric Methode lica Call or Multicall !!!
47peysche |posted February 1 2009
Sorry for the Typos :-(
Peysche
48thE_iNviNciblE from Oldenburg|posted February 6 2009
@peysche:
i’ve tried .NET 2008 now i can add a web reference but this works without error… but not really…
try this:
E:\xprogramme\Microsoft Visual Studio 9.0\VC>wsdl /l:vb /protocol:SOAP http://www.yourserver.de
this is showing a large (german) error message with a related link http://www.ws-i.org/Profiles/BasicProfile-1.1.html
on PHP5 SOAP works..
49eldude |posted February 8 2009
Is there a general timeline for when this will be rectified? Magento is a non-starter without it.
50eldude |posted February 8 2009
I really want to move three sites I have to magento but I must have a compliant API to interface with a .NET back-end workflow module. Is there any way to get any kind of estimate of when this will be available. My busy season is approaching so I am under a lot of pressure to make decision on the platform I am moving to. Thank you.
51japes |posted February 13 2009
We are also a no go till we get a working Soap API that’s compatible with Visual Studio 2008. We manage tens of thousands of products, inventory availability, pricing, etc., through a custom .Net back end.
Any kind of ETA would be REALLY helpful. What would be even more glorious is a hack that fixes the problem till the real fix comes out.
Magento really is a great platform - great job Magento Team… We really do love your software. We just can’t launch till this Soap issue is resolved :(.
Thanks for all your hard work guys.
52RoyRubin from Los Angeles, CA|posted February 13 2009
A resolution is expected in Magento 1.3 with a release date of March. Hope this helps.
53japes |posted February 13 2009
Awesome! Thanks for the quick response. Is there any workaround for the time being? Thanks!
54eldude |posted February 14 2009
Will that include documentation? I don’t know about anyone else but the current documentation is too general so we would not be able to use the API without it. For example, the documentation says will return an array - but without the specifics of what the array is made up of, etc. it is of no use. I want to move multiple sites to magento but I must have an API, with documentation to use it. Thank you!
55boardwalk from Cornwall, UK|posted February 16 2009
Look forward to version 1.3 could really do with the api, currently exporting and importing through a custom php script and is very slow.
James
56Manoj.tripathi |posted March 6 2009
Getting the following error:
The type CustomerInfo was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type CustomerInfo was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
Source Error:
Line 77: [return: System.Xml.Serialization.SoapElementAttribute("callReturn")]
Line 78: public object call(string sessionId, string resourcePath, object args) {
Line 79: object[] results = this.Invoke("call", new object[] {
Line 80: sessionId,
Line 81: resourcePath,
Source File: d:\WebSite3\App_Code\MagentoService.cs Line: 79
Any solutions. Thanks in Advance.
57Manoj.tripathi |posted March 6 2009
Hi All,
I am trying to consume the Magento web services in C#.Net.
I followed the steps:
1. open the wsdl.xml in IE.
2. Copy all the contents & paste the contents into my.wsdl file.
3. Remove all the extra characters from my.wsdl file. like ‘-’ , until the file open correctly in IE.
4. C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ wsdl.exe my.wsdl
5. It will create MagentoService.cs as a result of step 4. This is the proxy file of web service.
6. write code in visual studio 2008
using System;
using System.Xml;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MagentoService m = new MagentoService();
string login = m.login("apiUserName", “apiUserKey"); //It will return the session ID.
ArrayList newCustomer = new ArrayList();
newCustomer.Add("firstname");
newCustomer.Add("middlename" );
newCustomer.Add("lastname");
newCustomer.Add("suffix");
newCustomer.Add("email");
newCustomer.Add(MD5Con.EncodePassword("password"));
newCustomer.Add(0);
newCustomer.Add(0);
object custid;
custid = (object)m.call(login, “customer.create”, newCustomer );
XmlNode[] wtf = (XmlNode[])m.call(login, “customer.info”, custid);
}
}
public static class MD5Con
{
public static string EncodePassword(string originalPassword)
{
//Declarations
Byte[] originalBytes;
Byte[] encodedBytes;
MD5 md5;
//Instantiate MD5CryptoServiceProvider, get bytes for original password and compute hash (encoded password)
md5 = new MD5CryptoServiceProvider();
originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword);
encodedBytes = md5.ComputeHash(originalBytes);
//Convert encoded bytes back to a ‘readable’ string
return BitConverter.ToString(encodedBytes);
}
}
Above code is working, but it is inserting balnk record.
I customer_entity table it is inserting balnk in email field.
I am guessing there is some error in object mapping.
Can any one tell how we can create the equivalent code as below, which will map correctly.
// Create new customer
$newCustomer = array(
‘firstname’ => ‘First’,
‘lastname’ => ‘Last’,
‘email’ => ‘test@example.com’,
‘password’ => ‘password’,
‘store_id’ => 0,
‘website_id’ => 0
);
$newCustomerId = $proxy->call($sessionId, ‘customer.create’, array($newCustomer));
This array is important , please tell the equivalent code for C#.
I will be thankful if any one can give the correct response. Thanks in advance.
58eldude |posted March 17 2009
Any ETA update on the .net compliant API?
Thank you
59RoyRubin from Los Angeles, CA|posted March 17 2009
End of March with the release of 1.3. Hope this helps.
60dEeds |posted March 31 2009
The new WSDL in 1.3 still does not work in Visual Studio 2005 and 2008.
61boardwalk from Cornwall, UK|posted March 31 2009
Hi dEeds, Thanks for posting, is it still the same problem as previous versions? I was hoping that this release would enable me to use Soap Services from VFP but I assume as it doesn’t yet work with Visual Studio probably wont in VFP either.
62dEeds |posted March 31 2009
After is browsed the Diff to this version, it seems that there is / there are new WSDLs in this version, but I can not find the location in any documentation or changelog. It will follow, I guess.
63Jake99 |posted April 1 2009
Has anyone gotten version 1.3 to work with .Net? I thought this version was going to have a .net compliant API.
64oxinet |posted April 6 2009
I’m having problems with the API in 1.3 too. I get:
“The datatype ‘urn:Magento:catalogProductAttributes’ is missing.”
when I run the wsdl.exe program. That seems to be used just once in the “catalogProductInfoRequest” message. I tried hacking the WSDL but got more errors and I thought i’d better post here!
65oxinet |posted April 6 2009
Oh and I forgot to mention - this is after installing the patch mentioned here:
http://www.magentocommerce.com/blog/comments/soap-webservice-api-wsdl-issue-for-php-version-526/
and also that this blog entry mentions a new url for the “compatible” wsdl which is:
<your server>/api/v2_soap?wsdl
66oxinet |posted April 6 2009
I’ve kind of found a hack, and have posted my experiences on my blog:
http://gordonsbits.wordpress.com/2009/04/06/magento-webservice-api-with-aspnet-part-1/
It’s let me get started anyway, even if it’s not completely correct.
67eldude |posted April 6 2009
The Magento team really should fix these kinds of problems with the API. It is disappointing that they say their recent update made the SOAP interface friendlier with .NET and JAVA, but it really doesn’t. SOAP is a platform independent protocol, and it really should be the standard for web services. XML-RPC does work with this release with some work but that is an old an inferrior standard. I wonder if the Magento team is having a difficult time defining the SOAP interface. It might be a problem with the way the data is structured, and it all goes back to the database being a EAV model? Some communication sure would be appreciated - there are a lot of us that this is mission critical for and a deal killer for lots of sophisticated potential magento users.
68oxinet |posted April 6 2009
Judging by the pretty minor hacks I made to the WSDL, I don’t think it’s a fundamental flaw in their model - I just think it hasn’t been tested properly!
69eldude |posted April 6 2009
If anything you do after connecting and getting a session ID returns an error, I would say not being tested properly is a bit of an understatement. If they had done any testing at all they would have seen that it doesn’t work. Your hacks aren’t supported by upgrades so this just layers in problems going forward - we are looking for a serious solultion here....
70thE_iNviNciblE from Oldenburg|posted April 6 2009
We hope magento ofers as soon as possible a solution… i’m wating for real .NET support for a long time…
their model works with php and soap i’m using it…
71ruupie |posted April 6 2009
Anyone got this new v2_soap api working with Java (Axis) ?? I cannot imagine that the Magento Team released a completely renewed wsdl-api totally untested..