eCom api update order Invalid input (error code: 400)

Nick_TNick_T Member Posts: 5

I'm trying to use the eCom api to update the orders shipment status in node js.


main.js

    socket.on("setStatusVerzonden", (response) => {


        var orderdata = response.data;


        var data = {

            "order": {

                "shipmentStatus": "shipped"

            }

        }


        api.sendApiPutRequest("orders/" + orderdata.id + ".json", JSON.stringify(data), (res) => {

            console.log(res);

        });


    })


WebshopApi.js:


    sendApiPutRequest(subLink, data, callback){

        https.put("https://" + this.apiKey + ":" + this.apiSecret + "@" + this.cluster + "/" + this.language + "/" + subLink, data, (error, respones, body) => {

            callback(body);

        })

    }


It returns {"error":{"code":400,"method":"UPDATE","request":"\/nl\/orders\/158702244.json","message":"Invalid data input."}}, what am I doing wrong?

2 comments

  • Nick_TNick_T Member Posts: 5
    edited July 30

    It doesn't give invalid input anymore, but it also doesn't change the order.

    main.js

        socket.on("setStatusVerzonden", (response) => {


            var orderdata = response.data;


            var data = {

                "order":{

                    "id":1

                }

            }


            api.sendApiPutRequest("orders/" + orderdata.id + ".json", data, (res) => {

                console.log(res);

            });


        })


    WebshopApi.js


        sendApiPutRequest(subLink, data, callback){


            https({

                url: "https://" + this.apiKey + ":" + this.apiSecret + "@" + this.cluster + "/" + this.language + "/" + subLink,

                method: 'PUT',

                json: data

            }, (error, request, body) => {

                callback(body);

            });


        }

  • Nick_TNick_T Member Posts: 5

    I fixed the issue, it had to do with the way I was calling the put request.

Sign In or Register to comment.