1

quick broad question. Does the REST API in Magento 2 still accept XML input? According to the introduction, it does. But further on in the documentation, there is no mention. I have been able to receive XML Formatted data (product) but I have not been able to submit any new products.

If this is still possible, is there any documentation I have overlooked?

1
  • Could you share your request XML and code ? Jan 29, 2018 at 21:10

1 Answer 1

1

Yes, the REST API supports payloads in XML format, but it turns out they need to be specially wrapped in magento_api tags. The content-type will also need to be set to application/xml. Here's an example on how to create a customer:

<magento_api>
   <customer>
      <addresses>
         <element>
            <city>New York</city>
            <countryId>US</countryId>
            <defaultBilling>true</defaultBilling>
            <defaultShipping>true</defaultShipping>
            <firstname>Big</firstname>
            <lastname>Foot</lastname>
            <postcode>10755</postcode>
            <region>
               <region>New York</region>
               <regionCode>NY</regionCode>
            </region>
            <street>
               <element>125 Oak Ave</element>
            </street>
            <telephone>512-444-1111</telephone>
         </element>
      </addresses>
      <email>[email protected]</email>
      <firstname>Big</firstname>
      <lastname>Foot</lastname>
   </customer>
</magento_api>

Note that array data members will need their own tags, like the element tags in the example above.

Apologies for this miss in documentation, and we will work on adding this info to the topic!

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.