2

There are multiple store views in my site. I created a customer and set his store view to some value that is not the default.

Use the rest api to change the first name of the customer (Like: put to PUT rest/V1/customers/8)

I used the following body

{ "customer":         {
            "id": 1,
            "group_id": 1,
            "default_billing": "0",
            "default_shipping": "0",
            "created_at": "2019-05-13 14:33:11",
            "updated_at": "2019-05-13 14:33:11",
            "created_in": "alternate store view",
            "email": "xxx@redacted.com",
            "firstname": "firstname alternate",
            "lastname": "lastname",
            "gender": 0,
            "website_id": 1,
            "addresses": [],
            "disable_auto_group_change": 0
        }
}

So All the fields not passed in the PUT call are not changed (Including store_id) but it changed the store_id to default store_id.

I need to know why it changed the store_id, is store_id is mandatory if yes then why it does not show the error or it just save with default store_id if store_id not given in the request.

Any help, experience and knowledge sharing would be appreciated.

1

Using this endpoint

"PUT rest/V1/customers/8"

means you are calling the default store view, So if you want to set another store id you have to use another endpoint like this

"PUT rest/{store_code}/V1/customers/8"

the above endpoint will set the correct store_id depending on the store code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.