Magento – Magento 2 Customer update API using CURL

magento2

I am able to get create, view and delete using curl to a Magento 2.1 site. However, update seems to be not working. In this example I have already grabbed my token: curl -X POST "http://www.russellalbin.com/index.php/rest/V1/integration/admin/token" -H "Content-Type:application/json" -d '{"username":"someusername", "password":"somepassword"}'

That returns my Bearer that is used below ( masked of course for this posting )

curl -X "PUT" "http://www.russellalbin.com/rest/V1/customers/2" \ -H "Authorization: Bearer MASKEDCODEqoopucla3gt3bh" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{"customer": {"id": 2,"dob": "string","firstname": "updatedFn","lastname": "UpdatedLN","middlename": "updatedMN",},}'

I have a customer with the ID of 2. This request returns the following message pretty much no matter what I use for my json

{"message":"Decoding error."}

Is this still an issue with the version 2.1? I think I read that in 2.0.x it was causing issues but I never validated the complaints until now.

SOLVED
Bad JSON was to blame, here is an example of a working json

'{"customer": {"id": 2,"dob": "1972-08-20 00:00:00","firstname": "updatedFn","lastname": "UpdatedLN","middlename": "updatedMN", "email": "test@test.com", "website_id":1}}'

Best Answer

Bad JSON was to blame Here is a good version of JSON that did work with the above example

{"customer": {"id": 2,"dob": "1972-08-20 00:00:00","firstname": "updatedFn","lastname": "UpdatedLN","middlename": "updatedMN", "email": "test@test.com", "website_id":1}}