Magento2 supports two formats of the messages for REST APIs: json and xml. Let's take json as an example: the api call for the service you created will looks like this:
curl -X POST "http://magento.url/rest/V1/vakri/update" -H "Content-Type: application/json" -d '{"xml": "<OrderEventNotification Id="E201602261456522075"> .. "}'
As you see here, you should have field, "xml", which corresponds to input parameter name of the method.
For XML it might be a bit more tricky, I would assume something like
curl -X POST "http://magento.url/rest/V1/vakri/update" -H "Content-Type: application/xml" -d '<xml>"<OrderEventNotification Id="E201602261456522075"> .. "</xml>'
In any case, there will be a problem if xml code contains characters which can break the request json/xml structure. One way to overcome that is to obfuscate xml string with some encoding, let's say base64, or escape all dangerous characters. In API service implementation you would need to do reverse operation.
Another, and much better way, is to actually create the Data Object, which represents the data from the XML file. Instead of sending raw XML string, you'll just use possibilities of Web API framework to serialize/deserialize data.
namespace Ezprints\Valkyrie\Model\Api\Data;
interface OrderEventNotificationInterface
{
/**
* @return string
*/
public function getId();
/**
* @return string
*/
public function getOrderId();
/**
* @return string
*/
public function getEZPReferenceNumber();
/**
* @return string
*/
public function getAcceptedDateTime();
}
namespace Ezprints\Valkyrie\Model\Api;
interface ValkyrieStatusUpdateInterface
{
/**
* Parse the notification XML and handle accordingly
*
* @api
* @param Data\OrderEventNotificationInterface $orderNotification
* @return Data\OrderEventNotificationResponseInterface
*/
public function processVaklyrieStatusUpdate(Data\OrderEventNotificationInterface $orderNotification);
}
API call will looks like:
curl -X POST "http://magento.url/rest/V1/vakri/update" -H "Content-Type: application/xml" -d '<id>E201602261456522075</id><order_id> 000000024</order_id><e_z_p_reference_number>0-01-7899-201602242228-0027-3808</e_z_p_reference_number><accepted_date_time>2016-02-26T21:27:55<accepted_date_time>'
Best Answer
You need to create custom module for this functionality .
Below are the summarized point for custom module and its code .
Now Coming on the code , See below file wise code for more clarity.
Events.xml file :
extension_attributes.xml (Here creating custom extension_attributes for image)
Observer file.php(Ex - Categorysaveimage.php)
Note : As i mention i have done this module to save image of category using rest api , same way you can do as per your need .
Hope it helps..