Importing companies with custom fields

I am trying to import a CSV with custom fields but I am having trouble finding the right format for the custom fields.

I am using code based on this curl from the docs (Freshdesk)

curl -v -u yourapikey:X -H 'Content-Type: multipart/form-data' -F "file=@sample.csv" -F "fields[name]=0" -F "fields[email]=2" POST 'https://domain.freshdesk.com/api/v2/companies/imports'

I have tried fields[my_custom_field]=4, fields[custom_fields][my_custom_field]=4, fields[custom_fields[my_custom_field]]=4 and many other variations but can’t get it to work.

I always get an error like the below or similar.

{"description":"Validation failed","errors":[{"field":"fields","message":"Invalid fields: my_custom_field","code":"invalid_value"}]}

Can you help?

Hi Joel,

Hope you are doing good.

I guess your query is on how to access the custom fields. You need to append cf before the custom field name. (This applies to ticket custom fields. For contact/company custom fields you can specify the custom field name without any prefix). Refer https://support.freshdesk.com/en/support/solutions/articles/216553

For example :
if you custom field name is test then you should access it like cf_test

Hope this helps.

Regards,
Mughela chandresh

1 Like

Hi Mughela,

That sorted it out. Thanks for the help. :slight_smile:

2 Likes