Update user attributes stored as JSON via API

Hi,

We have a user attribute set up in our org for 'Divisional Access' which defines which divisions and brands within the org each user has access to. We have decided to store this as a JSON object, as we can have the following structure:
{divisions:["US", "INT", "UK",...], brands:["Brand A", "Brand B"]} which is handy as a user may have access to one or multiple divisions and brands.

However we want to use the Retool API to update user attributes and it appears the API only allows the value to be a string.
When I send the desired object in the API call I get the error error:"{"success":false,"message":"Expected string, received object: value"}". When I send the send the object as a string I get the following error: error:"{"success":false,"message":"Value is not valid JSON"}".
Is there a work around for updating object user attributes via the API or do we need to redesign our attributes so they are just strings?

2 Likes

Following as I also have json objects as attributes and was planning a dashboard to update them in the following months.

Hi @james-hollis! Welcome to the community. :slightly_smiling_face:

I think the best workaround here is to stringify the JSON attribute in the body of your request. Retool was able to correctly parse it as JSON upon receipt during my testing!

I hope that helps! Let me know if you have any questions.

1 Like