Sometimes getting 400 Error while trying to update ticket

Hi Team,

We are updating the group and custom ticket fields of a ticket using the “Update ticket” API. Most of the time, tickets are reassigned to the appropriate group and custom fields are updated properly.

But sometimes, we are getting a “400” error even though all the required values are passed to the request.

Please find the code snippet below.

function updateCustomeFieldForConversation(args, etsGroupIDValue, detailsList) {

  return new Promise(async function (resolve, reject) {
    let req_body = {
      group_id: parseInt(etsGroupIDValue),

      custom_fields: {
        cf_group_id: detailsList.group_id,
        cf_agent_id: detailsList.responder_id,
      },
    };

    let basicKey = getToken(args.iparams.ApiKey);

    $request
      .invokeTemplate("upd_cus_field_for_con", {
        context: {
          path: `/api/v2/tickets/${args.data.conversation.ticket_id}`,
          key: basicKey,
        },
        body: JSON.stringify(req_body),
      })
      .then(
        function (body) {
          console.log(
            "----Log of updated ticket by conversation----",
            body
          );
          resolve(true);
        },
        function (error) {
          console.log(
            "Error in updateCustomeFieldForConversation function",
            error
          );
          reject(error);
        }
      );
  });
}

Please find the screenshot of the log below.

We are invoking the same request a second time if the ticket update request fails, but a second time too, we are getting the same error.

Looking forward for suggestions to fix this issue.

Thanks,
Suman.

Hello @Suman_Chinnaraju

Can you please share the cURL of the same which is not working?

Thanks for the reply, @adarsh. Since the ticket was created via email, one mandatory field value was null, so when we tried to update the ticket properties, we got a 400 error since the mandatory field value is null or undefined.