Last active
February 22, 2021 12:28
-
-
Save molotovbliss/3c7352f774873fb737c3 to your computer and use it in GitHub Desktop.
Using cURL via CLI to debug Magento's XML-RPC API calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If any exceptions are encountered due to 3rd party/local observers debugging can be questionable as no log | |
is created to determine root cause. This mini doc covers how to use the XML-RPC API in Magento to test a | |
product update API call that is returning a 500 internal server error due to an observer firing in 3rd party | |
code. Using some simple XML docs prepared for login and the request it is easier to see the Fatal error | |
returned for a request, in this example product.update. | |
xmlrpclogin.xml contents: | |
<?xml version="1.0"?> | |
<methodCall> | |
<methodName>login</methodName> | |
<params> | |
<param> | |
<value>username</value> | |
</param> | |
<param> | |
<value>password</value> | |
</param> | |
</params> | |
</methodCall> | |
CURL call with login via CLI: | |
curl --data @xmlrpclogin.xml http://domain.com/api/xmlrpc/ | |
Session ID returned, copy and insert | |
xmlrpcproductupdate.xml contents: | |
<?xml version="1.0" encoding="UTF-8"?> | |
<methodCall> | |
<methodName>call</methodName> | |
<params> | |
<param> | |
<value> | |
<string><![CDATA[INSERT SESSION ID HERE]]></string> | |
</value> | |
</param> | |
<param> | |
<value> | |
<string><![CDATA[catalog_product.update]]></string> | |
</value> | |
</param> | |
<param> | |
<value> | |
<array> | |
<data> | |
<value> | |
<string><![CDATA[product_sku]]></string> | |
</value> | |
<value> | |
<struct> | |
<member> | |
<name>visibility</name> | |
<value> | |
<i4>1</i4> | |
</value> | |
</member> | |
<member> | |
<name>status</name> | |
<value> | |
<string /> | |
</value> | |
</member> | |
<member> | |
<name>name</name> | |
<value> | |
<string><![CDATA[Product Name]]></string> | |
</value> | |
</member> | |
<member> | |
<name>categories</name> | |
<value> | |
<array> | |
<data /> | |
</array> | |
</value> | |
</member> | |
<member> | |
<name>description</name> | |
<value> | |
<string><![CDATA[Product Description Here.]]></string> | |
</value> | |
</member> | |
<member> | |
<name>websites</name> | |
<value> | |
<array> | |
<data /> | |
</array> | |
</value> | |
</member> | |
<member> | |
<name>additional_attributes</name> | |
<value> | |
<struct> | |
<member> | |
<name>single_data</name> | |
<value> | |
<struct /> | |
</value> | |
</member> | |
</struct> | |
</value> | |
</member> | |
<member> | |
<name>price</name> | |
<value> | |
<double>29.90</double> | |
</value> | |
</member> | |
<member> | |
<name>msrp_enabled</name> | |
<value> | |
<string /> | |
</value> | |
</member> | |
</struct> | |
</value> | |
</data> | |
</array> | |
</value> | |
</param> | |
</params> | |
</methodCall> | |
curl --data @xmlrpcproductupdate.xml http://domain.com/api/xmlrpc/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment