cancel
Showing results for 
Search instead for 
Did you mean: 

Why increment_id changed when update order state /status using rest api ?

Why increment_id changed when update order state /status using rest api ?

I want to update order status/state usging webapi 

here is my testing code :

$data = [
'entity' => [ 
    'entity_id'=>37,
    'state'=>'processing',
    'status'=>'payment_finished',    
]
];
$ch = curl_init();

$post = json_encode($data);
$site_path = $localurl."/index.php/rest/V1/orders';
$authorization = "Authorization: Bearer $token";
curl_setopt($ch, CURLOPT_URL, $site_path);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

$result = curl_exec($ch);

and when this code runs, the state and status updated correctly , but the increment_id changed from previous to '00000001' . 

Can anyone help me with this problem?


4 REPLIES 4

Re: Why increment_id changed when update order state /status using rest api ?

I'm also facing the same issue. When we pass the increment_id along with the entity_id then it updates correctly without new increment_id

Re: Why increment_id changed when update order state /status using rest api ?

You have to pass 'increment_id' in BODY post data like below 

$data = [
'entity' => [ 
    'entity_id'=>37,
'increment_id'=>00000001, 'state'=>'processing', 'status'=>'processing', ] ];

Re: Why increment_id changed when update order state /status using rest api ?

You have to pass 'increment_id' in BODY post data like below

$data = [
'entity' => [
'entity_id'=>37,
'increment_id'=>00000001,
'state'=>'processing',
'status'=>'processing',
]
];

Re: when using this code i get this error

Hello, In this code I have find one error is coming like:

 

in this line: $authorization = "Authorization: Bearer $token";

 

syntax error, unexpected 'Authorization'