Update Ticket Filed from Custom App Not working

cf_product_type is custom dropdown field that has the exact same value being passed as an option.

Request on Custom APP server.js file
  const key = '{{key}}';
  const freshEndpoint = 'https://{{domain}}.freshdesk.com/api/v2/tickets/' + options.ticket_id;
  
    const callOptions = {
        method: 'put',
        body: JSON.stringify({
            custom_fields: {
                cf_policy_numbers: options.policy_number,
                cf_product_type: options.policy_type,
            }
        }),
        headers: {
            'Authorization': 'Basic ' +  buffer.from(key + ':X').toString('base64'),
            'Content-Type': 'application/json'
        }
    };
    fetch(freshEndpoint, callOptions).then(res => res.json()).then((res) => {
        console.info('RESPONSE', res);
        if(res === 'No Data Found') {
            renderData(null, JSON.stringify({
                notFound: true
            }));
        }
        renderData(null, JSON.stringify(res));
    });
Error from logs: 

Url to update ticket field https://{{domain}}.freshdesk.com/api/v2/tickets/90919
RESPONSE {
  description: 'Validation failed',
  errors: [
    {
      field: 'cf_product_type',
      message: 'Unexpected/invalid field in request',
      code: 'invalid_field'
    }
  ]
}

Can you confirm if the name of the custom field is correctly given? Form the error it seems like the custom field is not present in Freshdesk.

1 Like

I’m certain about the field name matching the value sent.

@Sahithi,

Are you testing this in a sandbox environment or in production? The reason I ask is because I have seen the naming schema for custom fields be labeled differently in the sandbox than they are in production. Therefore if you are going off what the custom field is labeled in production and have the application running in your sandbox the field name could be incorrect as the error suggests.

I often have console.log the payload information in which ever environment I am working, just to verify custom field names are all correct.

Hope this helps.

-Zach

1 Like

Thanks for the reply Zach. I did my testing on prod account as well. The field name remains the same but in prod the custom field name has few digits suffixed at the end like “cf_product_type656776”. The digits seem to be unique for each ticket. Similar case with some other custom fields.