Custom fields updates don't work? Both user(old API) and member(old API)

I am convinced none of the update APIs work with custom fields. Can someone show me sample code that works with custom fields AND actually updates the backend?

Here is what all I have tried -
First off, I have two fields whitelisted or entered as custom fields with text values in the member/contact area. I copy pasted the names into code to ensure I wasn’t messing up the spelling of the field.

Fetching from both request/responsese from logs -

Attempt 1: old API(users) - as a simple string value
Request :
[{“customFields”:{“DeliveryInstructions”:“abc”}}]
// I added the user ID to the request as well - I am simply showing the core part of the request
Response :
[“server responded with - {"message":"Unexpected value for StringValue","details":{}} (400)”]"

Attempt 2: old API(users) - with value string as object
Request :
[{“customFields”:{“DeliveryInstructions”:{“0”:“a”,“1”:“b”,“2”:“c”,“3”:“s”,“4”:“s”,“5”:“s”}}}]
// I added the user ID to the request as well - I am simply showing the core part of the request
Response :
“[“server responded with - {"message":"Unexpected value for StringValue","details":{}} (400)”]”

Attempt 3: New API(members) - with value as object
Request :
“[{“contactDetails”:{“customFields”:{“DeliveryInstructions”:{“0”:“a”,“1”:“b”,“2”:“c”}}}}]”
// I added the user ID to the request as well - I am simply showing the core part of the request

Response :
“[{”_id":“4174fa35-1d92-4953-ac03-77a7c913e967”,“loginEmail”:“XXX@yahoo.com”,“status”:“APPROVED”,“contactId”:“4174fa35-1d92-4953-ac03-77a7c913e967”,“privacyStatus”:“PRIVATE”,“activityStatus”:“ACTIVE”,“_createdDate”:“2022-03-30T06:29:31.000Z”,“_updatedDate”:“2022-03-30T06:29:31.182Z”,“lastLoginDate”:“2022-03-31T06:45:33.000Z”,“contactDetails”:{“firstName”:“XXX”,“lastName”:“XXX”,“phones”:[“123”],“emails”:[“XXX”],“addresses”:[{“_id”:“b10d7f54-e401-4ff6-a8d0-e3f2c6ff6c7e”,“addressLine”:“XXX”}],“customFields”:{}},“profile”:{“nickname”:“XXX”,“slug”:“XXX”}}]"

Note: All XXX/123 are PII which I have hidden.
Here the call succeeds but nothing is actually written to the backend, since 1) it is not returned in the response and 2) is also not available in the contact/member detail via the Wix frontend

Attempt 4: New API (members) - with value as a string
Request:
“[{“contactDetails”:{“customFields”:{“DeliveryInstructions”:“abc”}}}]”
// I added the user ID to the request as well - I am simply showing the core part of the request

Response:
“[“message: Expected an object\ndetails:\n applicationError:\n description: Bad Request\n code: BAD_REQUEST\n data: {}”]”

It is much more complicated.

Please add value to the member via the Wix dashboard.

Then, get that member with his ID so you know how custom fields are structured.

Then, anytime, when you want to update/add the member’s custom field, use the structure retreived.

You will never know the “key” of the custom fields without adding a test value through the native dashboard. It usually looks like “custom.myCustomFieldName”: { name: “XX”, value: “XX”}

Oh wow that is convoluted. They should really update their documentation to say all this. Trying it now…

@certified-code Thanks for your help - I dont think I’d have solved it otherwise…

So that worked for one of the fields. Any ideas on why some fields are returned when querying for the member and some aren’t?

If the field is empty, then it will not return.

If the member field is not added to the member profile, it won’t work: https://support.wix.com/en/article/customizing-your-member-profile-fields

Contact’s custom field does not automatically added to member’ field.

Thanks @certified-code !!

You’re the best! OMG this was frustrating. I was wondering why we were able to include spaces and what not within the field keys.

“Facebook Link” for example would use the key as:

custom.facebook-link

For a total API n00b… first, assuming this is about the REST API, not the Velo client API, right?

I’m also trying to update site member custom fields via the API, & I’m trying to figure out if the above solution is the right endpoint for my use case as well.

Basically I made 8 custom fields that show on the member account page depending which pricing plan a member has purchased (entitling them to 4 appointments, as here, or 8 if they’re on the higher plan):

Figured out member ID is the same as contact ID, so I know how to get that.

I want to write single-use Calendly links to these fields via a PATCH request (I know, I know, it’s the only way to sell packages of appointments via Calendly; you have to send them a single-use link for each “free” prepaid appointment; I just want all those links available on their account page when they log in). The links will be overwritten with new ones by the API when they re-up their package and my automations generate new links.

I’ve gotten the custom field IDs and everything from an API playground request. They look like this:

{
“fields”: [
{
“namespace”: “custom”,
“key”: “custom.calendly-link-1”,
“displayName”: “Book Your 1st Session”,
“dataType”: “URL”,
“fieldType”: “USER_DEFINED”,
“createdDate”: “2023-05-16T20:24:06Z”,
“updatedDate”: “2023-05-17T00:26:39Z”,
“legacyId”: “395a601c-7e60-46a8-bdd9-fed2c4d24934”,
“wixSearchColumn”: “info_extendedFields_custom_string_97”
},
etc.

Assuming it’s the legacyId I need… or is wixSearchColumn the field key in the new API or something?

Anyway I want to make sure I’m using the right PATCH request. Tried this one (update member).

I sent a playground request using my test member’s actual ID, and it didn’t update the proper custom field:


Do I need to send more stuff in the body like in the Docs example? It came back 200 but just returned the member’s basic profile info, with no updated custom field.

Thanks for answering a dumb question, anyone!

Hi, I’m still not able to include/update custom fields when registering new members from code
authentication.register(email, password, options)
I tried everything I know and searched for long hours but still not able to find what is the exact key for each custom field. You mentioned that we can know it by “adding a test value through the native dashboard”. How to do that?
thx