422 error with Customer metafields both create & Update
Closed this issue · 2 comments
I'm not sure if this is a 'me' error or a versioning issue or something else entirely
Started by creating a customer and was getting 422 error on the metafields. Thought that maybe it needed to create customer then update, same error.
Customer is successfully created without metafields,
From this, I believe I should be able to use the metafields on creation of the customer if I can figure out the 422 error.
The MetaField shown is a list of months, 3 characters, all uppercase and a 13th entry for "No Answer". They are already created in the shopify admin and are visible and useable under the customer when the customer is created via the API.
This is the endpoint update is using /api/2024-07/customers/xxxxxxxxxxxx.json (xxxxx = the customer id)
Update code (VB.Net) being used;
updMetaCustomer = Await service.UpdateAsync(TestId, New ShopifySharp.Customer() With { .Metafields = New List(Of ShopifySharp.MetaField)() From { New ShopifySharp.MetaField() With { .Key = "customer_birth_month", .[Namespace] = "custom", .Type = "list.single_line_text_field", .Value = "JUN" } } } )
Error 422 shows;
(422 unknown) value']: is invalid JSON: unexpected token at 'JUN'.
This is the same error on customer creation when using metafields.
There was some talk about whether .Type should be .ValueType but I'm not familiar enough with the versioning to know. FWIW I have no access to ValueType within metafield
Any help appreciated.
It was me....
Have to serialize a single element array of the value you want to select from the list type - can't just be a plain string.
Oh, glad you got it figured out!