update customer note using Admin API

asimtahir
New Member
7 0 0

Hi there. In my Shopify Theme I want my customers to be able to update their notes from their account settings. I'm trying to use Customer API (https://shopify.dev/docs/admin-api/rest/reference/customers/customer#update-2020-04) via a Private App. like in the example.

$client = new Client();
$response = $client->put('https://neno-site.myshopify.com/admin/customers/3857938448459.json', [
'headers' => [
'X-Shopify-Access-Token' => 'some-api-key',
'Accept' => 'application/json'
],
'customer' => [
"id"=> 3857938448459,
"email"=> "useremail@mailinatore.com",
"note"=> "Store Names:Testing mode"
]
]);
return $response->getBody();

 and in the response, it does not update the Customer Note.

0 Likes
_JCC_
Shopify Staff
Shopify Staff
145 20 26

Hey @asimtahir ,

Happy to help you out with this.

I don't see anything wrong with the request payload. If you could provide the x-request-id from the response headers where the customers put request is not updating the note I can look into this further. 

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
asimtahir
New Member
7 0 0

Hi @_JCC_ 
I'm very happy to say that finally I found my mistake and resolve that.
Actually the issue was the JSON formate, and the right formate is this

'json' => [
"customer"=> [
"id"=> $request['user_id'],
"note"=> $request['customerNote']
]
]
0 Likes