How To Update Shipping Of An Order Via Api

Hi,

How can I update na existing order programatically via API?

As per https://docs.cs-cart.com/latest/developer_guide/api/entities/orders.html#update-an-order

I submitted a JSON object like the one below to /orders/124 and the server returned 200 OK + valid JSON response. But the Shipping and Company attributes have not been updated. I ensured that the shipping of id 10 exists.

{

order_id: 124

shipping_id: "10",

company: "Some Company"

}

Also tried to remove the order_id or pass whole shipping object rather than just the ID, but none of this worked. Always got 200 OK, but the data has not changed.

What is the correct way of doing this?

Sorry for posting it to Documentation forum, but I don't have permission to submit to Developer's Corner.

thanks

Jiri

Hello JiriMatejka

{

order_id: 124

shipping_ids: "10",

company: "Some Company"

}

shipping_id -> shipping_ids

shipping_ids = 10 must exists. there must be a delivery with this id. It cannot be any number.

Best regards

Robert

Thanks Robert for you answer.

Would you know how can I create a new shipment for an order?

I submitted a POST request to /api/shipments

{
"carrier": "Fedex",
"order_id": 126,
"products": [
{
"1529601775": "1"
}
],
"shipping": "PA"
"shipping_id": "8",
"user_id": "4",
"tracking_number": "FedexTrackingNr"
}

but am getting 500 Internal Server Error. If I make an intentional mistake, eg. broken JSON, then I get valid error message like this:

{
"message": "Bad Request: Syntax error, malformed JSON",
"status": 400
}

I ensured the order id, product item id, shipping and user exist. The carrier is a dummy string, is that OK?

Any idea how to resolve this?

thanks

Jiri

Hello

You miss the comma after "shipping": "PA"

Best regards

Robert

Hello

You miss the comma after "shipping": "PA"

Best regards

Robert

Thanks. The missing comma is just a typo in this comment. I sent a valid request to /api including the missing comma. If i sent such a malformed JSON to api then I get Bad Request: Syntax error... message which is logical and expected.

But If I send a valid (I believe it is valid) request, see below, then I get 500 Internal Server error.

{
"carrier":"Fedex",
"order_id":126,
"products":[
{
"1529601775":"1"
}
],
"shipping":"PA",
"shipping_id":"8",
"user_id":"4",
"tracking_number":"FedexTrackingNr"
}

Hello

Please try this

{
"carrier":"fedex",
"order_id":126,
"products":{"1529601775":"1"},
"shipping":"PA",
"shipping_id":"8",
"user_id":"4",
"tracking_number":"FedexTrackingNr"
}
Best regards
Robert

Hello

Please try this

{
"carrier":"fedex",
"order_id":126,
"products":{"1529601775":"1"},
"shipping":"PA",
"shipping_id":"8",
"user_id":"4",
"tracking_number":"FedexTrackingNr"
}
Best regards
Robert

Thanks, using fedex instead of FedEx worked.

Thanks for your help!

Jiri

Could you please advice how to create shipments for multiple products within one order? Do I have to create multiple shipping records?

thanks

Jiri

Hello

Please try:

{
"carrier": "FedEx",
"order_id": 15365,
"products": {"3224993888":1,"3074339062":1},
"shipping": "PA",
"shipping_id": "8",
"user_id": "1"
}
Best regards
Robert

Hello

Please try:

{
"carrier": "FedEx",
"order_id": 15365,
"products": {"3224993888":1,"3074339062":1},
"shipping": "PA",
"shipping_id": "8",
"user_id": "1"
}
Best regards
Robert

Thanks, that worked.

Hello

You are welcome :)

Best regards

Robert