Error when trying to save intercom user
victorfink opened this issue · 1 comments
Hello,
## Version info
- intercom-ruby version: 3.9.5
- Ruby version: 2.6.3
## Expected behavior
intercom = Intercom::Client.new(token: <MY_TOKEN>)
# to create user
user = intercom.users.create(email: "bob@example.com", name: "Bob Smith", signed_up_at: Time.now.to_i)
# retrieve user to change custom attribute
user = intercom.users.find(email: "bob@example.com")
user.custom_attributes["my_custom_attribute"] = 90
# saving the user
intercom.users.save(user)
The expected behavior would be to save the user, without error.
## Actual behavior
I get an error when the program reaches the line where the user is supposed to be saved.
## Steps to reproduce
See full code above
## Logs
Traceback (most recent call last):
7: from intercom_user_init.rb:19:in <main>' 6: from /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/api_operations/save.rb:27:in
save'
5: from /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/client.rb:119:in post' 4: from /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/client.rb:144:in
execute_request'
3: from /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/request.rb:56:in execute' 2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/net/http.rb:920:in
start'
1: from /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/request.rb:67:in block in execute' /Library/Ruby/Gems/2.6.0/gems/intercom-3.9.5/lib/intercom/request.rb:224:in
raise_application_errors_on_failure': The error of type '' is not recognized. It occurred with the message: User email, user_id or anonymous_id must be supplied and http_code: '400'. Please contact Intercom with these details. (Intercom::UnexpectedError)
I was using API version 1.4 and there's an issue where intercom.users.save(user)
will lead to an error.
What works in my case is the following.
If you have a user, with user_id = "user_2", you can do:
user = intercom.users.create(user_id: "user_2", custom_attributes:{"my_custom_attribute": 97})
This will successfully update its customer attributes. Be careful as you may have to change the scopes of your app.
Thank you Kunal from Intercom support for helping me solve this issue!