1

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": "[email protected]", "website_id":1}}'

2 Answers 2

0

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": "[email protected]", "website_id":1}}

0

I think you should use Postman for Restful API, It very easy for test api

Go to postman docs click here!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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