Update contact without setting a required field

I am writing a serverless app that will correct some of the records if not set. Specifically, onAccountCreate or onContactCreate, if country is set, use that value to set the territory and time zone.

The problem I am having is that there are some required fields which I do not have a value for. I want to set some of the fields w/o setting the required fields.

Here is my REST API call:

curl --location --request PUT 'https://***.myfreshworks.com/crm/sales/api/sales_accounts/16003120437' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token token=***' \
--data-raw '{
    "sales_account": {
        "website": "https://www.pksi.com/",
        "territory_id": 16000000266,
        "owner_id": 16000031274,
        "custom_field": {
            "cf_region": "APAC",
            "cf_country": "India"
        }
    }
}'

But industry_type_id and cf_business_type are required fields so I get an 400 error back because required field omitted.

I also tried to set them to null as follows:

curl --location --request PUT 'https://***.myfreshworks.com/crm/sales/api/sales_accounts/16003120437' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token token=***' \
--data-raw '{
    "sales_account": {
        "website": "https://www.pksi.com/",
        "territory_id": 16000000266,
        "owner_id": 16000031274,
        "industry_type_id": null,
        "cf_business_type": null,
        "custom_field": {
            "cf_region": "APAC",
            "cf_country": "India"
        }
    }
}'

So still I get 400 error / missing required field.

Is there any way to set some fields in REST API w/o updating requried fields that are currently unset?

Hi @stevemc

Hope you are fine.

One of my suggestions would be to retrieve the values of industry_type_id and cf_business_type using the viewAccount API and then use those values in the updateAccount API.

viewAccount API :
curl -H “Authorization: Token token=” -H “Content-Type: application/json” -X GET “https://domain.myfreshworks.com/api/sales_accounts/<sales_account_id>?include=business_type,industry_type”

Hope this helps. Feel free to ask if you have further queries.

Regards,
Mughela chandresh

Thanks for suggesting. Actually its important that I do check the values as you recommend but if the values are currently null I need to be able to leave them as null.

Ya, I understand that. Were those fields made as required recently and previously while creating some accounts that wasn’t required?

Fields have been required for quite some time. The accounts are being created without the required fields by the Outlook Contacts Sync.

The serveless app I am writing is attempting to fill in some of the required fields. let me explain how it works.

Following are required fields for our Accounts:

  • Region
  • Territory
  • Country
  • Business Type (Freshsales built-in field)
  • Industry Type (Freshsales built-in field)

The Servless App I am writing takes country from the Outlook Contact Sync and uses that to populate Region, Territory and Country. I wish to leave Business Type and Industry Type empty so that next time sales person tries to edit the record, they will be forced to enter values for those fields.

How can I accomplish this?