slack-ruby / slack-ruby-client

A Ruby and command-line client for the Slack Web, Real Time Messaging and Event APIs.
MIT License
1.19k stars 214 forks source link

Can't set custom field with #users_profile_set #430

Closed anton-smagin closed 1 year ago

anton-smagin commented 1 year ago

I'm trying to change custom field of slack user following official documentation

https://api.slack.com/methods/users.profile.set#custom_profile

::Slack::Web::Client
  .new(token: Settings.slack_admin_token)
  .users_profile_set(
    user: 'USERID', 
    profile: { fields: { { CUSTOM_FIELD_ID =>  { value: 'test' } } } }.to_json
)

but API returns me ok response with unchanged custom field.

Do I build profile wrong or what else I can do to change custom profile via API?

dblock commented 1 year ago

~I would first check what the library is sending over the wire here, then reproduce this with curl, and open an issue with Slack if it's on their side. Also, I am not sure you need to_json for that profile. That might be an issue.~

Do you have a double fields: { { } } there? Try profile: { fields: { CUSTOM_FIELD_ID => { value: 'test' } } }

anton-smagin commented 1 year ago

The problem was about custom field permissions. It was restricted to update it via API. Thank you for your help!