Skip to main content
Answered

Cannot update contact using golang


Iam using the golang package

https://github.com/intercom/intercom-go/p>

While iam trying to update my contact , getting error

Error :

400: invalid_document, either_email_or_user_id_present validation failed

Code:

ic := intercom.NewClient(token, "")

      contact := intercom.Contact{

         ID: "604720410292c92b2fbd598a",

         UserID:          "420",

         CustomAttributes: map[string]interface{}{"First Campaign Sent": "Yes boss"},

      }

      savedContact, err := ic.Contacts.Update(&contact)

Please help me for update contact using golang

Best answer by Roy

Hello @user461​ , Welcome to Interconnect ✨

 

1) Can you confirm that contact 604720410292c92b2fbd598a accseble from Intercom UI?

(To check this try to access the following URL: https://app.intercom.com/a/apps/b>YOURAPPID/users/604720410292c92b2fbd598a /all-conversations).

 

2) Accordingly to Github docs to update contact ID or User ID is required:

contact := intercom.Contact{
UserID: "420",
Name: "SomeContact",
CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Update(&contact)

or via ID:

contact := intercom.Contact{
ID: "604720410292c92b2fbd598a",
Name: "SomeContact",
CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Update(&contact)

Can you try the following advice and let me know if this helps?

 

Looking forward and have a great day.

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+5
  • Expert User
  • 1152 replies
  • Answer
  • May 18, 2021

Hello @user461​ , Welcome to Interconnect ✨

 

1) Can you confirm that contact 604720410292c92b2fbd598a accseble from Intercom UI?

(To check this try to access the following URL: https://app.intercom.com/a/apps/b>YOURAPPID/users/604720410292c92b2fbd598a /all-conversations).

 

2) Accordingly to Github docs to update contact ID or User ID is required:

contact := intercom.Contact{
UserID: "420",
Name: "SomeContact",
CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Update(&contact)

or via ID:

contact := intercom.Contact{
ID: "604720410292c92b2fbd598a",
Name: "SomeContact",
CustomAttributes: map[string]interface{}{"is_cool": true},
}
savedContact, err := ic.Contacts.Update(&contact)

Can you try the following advice and let me know if this helps?

 

Looking forward and have a great day.


  • Author
  • New Participant
  • 1 reply
  • May 22, 2021

Hi,

https://app.intercom.com/a/apps/YOURAPPID/users/604720410292c92b2fbd598a /all-conversations).

 

This url is accesible. But same error is happened.

Code :

contact := intercom.Contact{

         ID:              "604720410292c92b2fbd598a",

         Name:            "SomeContact",

         CustomAttributes: map[string]interface{}{"Status": "ss"},

      }

      savedContact, err := ic.Contacts.Update(&contact)

Error :

err 400: invalid_document, either_email_or_user_id_present validation failed

 

But following api is working for this id

contactDetails, err := ic.Contacts.FindByID("604720410292c92b2fbd598a")


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings