Modifying a user's user_option attributes via API

Our website allows our users to manage a small number of attributes of their Discourse profile. (Discourse is mostly used as a mailing list replacement)

We allow them to change their display name, bio, email address and how they wish to receive messages from Discourse.

For that last part we let the user choose whether they would like a digest or all emails via the attributes email_digests and mailing_list_mode.

Using C# (and RestSharp) I used to be able to PUT a request like this

/users/{username}.json?api_key={api_key}&api_username={api_username}

Then add the form data to the request email_digests=true&mailing_list_mode=false

In our previous version of Discourse, that worked great. Now that those attributes have moved to the user_option. I can’t get it to work.

I have tried posting using dotted identifiers (user_option.email_digests) no luck. I looked at the routes and there isn’t one specifically for getting or change the user_option (s)…I didn’t expect there to be, but, I’m just saying I looked :slight_smile:

Anyone out here that can point me in the right direction?

4 Likes

Not sure if this made a difference, but I changed the PUT URL to drop the .json and now everything seems to be working.

To figure that out, I started up Fiddler and made a change directly to my profile in Discourse. I was able to see how the form data was sent and it was exactly how I had it, but the URL was slightly different.

I’m sorry to waste the time of everyone that read this, but it is a good lesson learned for me. ALWAYS look closely at the little things (and monitor the network to see how it is supposed to work).

3 Likes