Update contact not working

Hi I am trying to update the contact on the other_companies field.
Docs mention an array of hashes, not sure what this means. What is the correct syntax?
I tried:

curl -u ${fd_api_key}:X -X PUT -H "Content-Type: application/json" -d '{"other_companies":["company_id": "30000147482"]}' "https://dataserviceshub.freshdesk.com/api/v2/contacts/30009644980"

error: {“code”:“invalid_json”,“message”:“Request body has invalid json format”}

Also tried

curl -u ${fd_api_key}:X -X PUT -H "Content-Type: application/json" -d '{"other_companies":["30000147482"]}' "https://dataserviceshub.freshdesk.com/api/v2/contacts/30009644980"

Error: {“description”:“Validation failed”,“errors”:[{“field”:“other_companies”,“message”:“It should contain elements of type key/value pair only”,“code”:“datatype_mismatch”}]}

please help.

1 Like

Hi Rakesh,

Welcome to community :slight_smile:

You need to provide other_companies in this format:

"other_companies":[
     { "company_id":25, "view_all_tickets":true },
     { "company_id":26, "view_all_tickets":false }
], 

Your request should look like this:

curl -u ${fd_api_key}:X -X PUT -H "Content-Type: application/json" -d '{"other_companies":[{company_id: "30000147482"}]}' "https://dataserviceshub.freshdesk.com/api/v2/contacts/30009644980"

Let me know if this doesn’t work. :slight_smile:

2 Likes