Jump to content

PUT order_histories works with postman but not in php


Recommended Posts

Very strange.

I need to update an order changing order status. I use PUT with postman service and works fine

I copy the php code and I put the code into a server. Calling the code I receive the error message

XML error : String could not be parsed as XML

XML length : 0

This is the code:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://xxxxxx.com/api/order_histories?ws_key=ABCDEFGH1243456768676876',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>'{
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <order_history>
    <id_order_state><![CDATA[4]]></id_order_state>
    <id_order><![CDATA[1]]></id_order>
  </order_history>
</prestashop>
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/xml'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

 

Others calls with GET or POST works fine.

I use https

Any idea ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...