"RequestAPI - Received unexpected response from Parent" Unable to get Toast Notifications to appear for ticket creation

Hello,

I have created an application that allows for a new ticket to be created when certain fields are filled in. This application takes the values of those fields and send them in a post request for ticket creation. The issue I am facing is the toast notifications that I have set up do not appear for this function. And I get this response when I log the response of the post request

image

This response is logged even if the post request returns 201 and the ticket is created. Here is the code snippet for the ticket creation function. Hoping someone can help me identify the issue. All other notifications where the “showNotification” function is set to run work as intended.

function createFreshserviceTicket (email, subject, description, agent, group) {
	client.request
		.post('https://<%=iparam.freshservice_subdomain%>.freshservice.com/api/v2/tickets', {
			headers : {
				Authorization  : 'Basic <%= encode(iparam.freshservice_api_key)%>',
				'Content-Type' : 'application/json;charset=utf-8'
			},
			body    : JSON.stringify({
				description  : `${description}`,
				email        : `${email}`,
				priority     : 1,
				status       : 2,
				source       : 1002,
				group_id     : parseFloat(group),
				responder_id : parseFloat(agent),
				subject      : `${subject}`
			})
		})
		.then(function () {
			showNotification('success', 'Ticket is successfully created');
			//Clears user input after posting data
			clearInputfields();
		})
		.catch(function (error) {
			console.error(error);
			showNotification('error', 'Unable to create ticket');
		});
}

Here is the function for showing notifications.

 function showNotification (status, message) {
	client.interface.trigger('showNotify', {
		type    : `${status}`,
		message : `${message}`
	});
}

Thank you in advance for any help offered.

-Zach

Hiya @Zach, I’m new here, and taking my first stab at this forum. So, this may not work, but:

From the API docs on create ticket, I see there are limited number of values that you can put for source, and 1002 isn’t one of them. Could that be the cause of the validation error?

Cheers.

1 Like

Thank you @kaustavdm,

Actually the 1002 is the allocated value for a custom source we created specifically to identify tickets created by the app. This attribute does not prevent a ticket from being created it just can’t be null, it could however be the cause to the strangely labeled log error when the RequestAPI is called, that I am not sure of.

I am hoping that the DevRel team can offer some insight on what the error might indicate.

Glad to have you a part of the forum. This place has a ton of information and the people are awesome!

1 Like

Thanks for the explanation and encouragement :slight_smile: TIL, there can be custom sources. :smiley:

I’ve reached out to the team and will get some eyeballs on this tomorrow. I’ll also try reproducing the issue on my end.

Hey @Zach,

Could you please check the following and confirm?

  1. If the error is printed by the catch function, maybe add another log with a string before console.error and check if it gets printed,
  2. could you share the complete response string displayed in the screenshot?

Stay Safe :slight_smile:

2 Likes