Skip to main content
Question

Potential issue with address book update favorite contacts API endpoint

  • May 19, 2023
  • 1 reply
  • 166 views

Hi all,

I am currently using the RC API to create an app and I'm making a contact list component. It lists all contacts and all favorite contacts on the page, and I'm trying to add functionality where you can add/remove contacts from favorites.

I'm using the PUT method on the /restapi/v1.0/account/~/extension/~/favorite with the body:

{records : [

{

id: `${contactId}`,

contactId: contactId

}

]} i.e. using the contact id as a unique ID. however when I list the favourites, the id field resets to 1 for some reason? I'm only adding one favorite at a time, and when I try to add another one, it will replace the previous one, presumably because the ID is the same. Just wondered if there's any way around this, whether there's a better way to do this or whether there's a potential bug with the API ?

Really appreciate any feedback and if you need more detail please ask!!

Cheers,

Ben

1 reply

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • 2318 replies
  • May 19, 2023

The id in a favorite contact record is an integer and is not the contact id. It's the ordinal number of a contact in the favorite contact list.

Remember that the update favorite contact API will override the entire favorite contact so you need to read the user favorite contact, then grab the records object from the response, and modify the record member data and use that records object to update the user favorite contact. Here is an example.

// read the user favorite contact 

// Response
response = {
  uri: 'https://platform.ringcentral.com/restapi/v1.0/account/80964xxx/extension/6228832xxx/favorite',
  records: [
    { id: 1, contactId: '18405126001' },
    { id: 2, contactId: '18405126401' },
    { id: 3, contactId: '18405126101' },
    { id: 4, extensionId: '6198663701' }
  ]
}
// Modify the records to change the second contact
var records = response.records
records[1].contactId = "5597152019"

// Then call the API to update the favorite contact using the modified records data.



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