Authentication suddenly not working

Hey everyone,

I’ve recently come across an issue with one of my custom apps giving a 401 status error. It was working perfectly fine a few weeks ago, and then suddenly stopped working without any changes on my end. It’s a basic program that retrieves all of the time entries for accounting purposes. Here is the function that is causing grief.

function ListAllTimeEntries() {
    var options = {
		headers: {
		  Authorization: `Basic <%= encode(iparam.apikey) %>`, // substitution happens by platform
		  "Content-Type": "application/json",
		},
	};
	//console.log(options);
	//const URL = `https://proviewit.freshdesk.com/api/v2/tickets?order_by=plan_work_date`;
	var i = 0;
	//console.log(String(currentMonth).padStart(2, '0'));
	var prevYear = currentYear;
	var prevMonth = currentMonth;
	if(prevMonth == 0){
		prevMonth = 12;
		prevYear--;
	}
	const URL = `https://proviewit.freshdesk.com/api/v2/time_entries?executed_after=` + prevYear + '-' +
	String(prevMonth).padStart(2, '0') + `-` + daysInMonth(prevMonth, prevYear) + `T02:00:00Z&executed_before=` + 
	currentYear + '-' + String(currentMonth + 1).padStart(2, '0') + `-` + daysInMonth(currentMonth + 1, currentYear) + 
	`T02:00:00Z`;
	console.log(URL);
	client.request
	  .get(URL, options)
	  .then(function ({ response }) {
		//console.log(response);
		const obj = JSON.parse(response);
		for (var timeEntry of obj){
			i++;
			timeEntries.push(timeEntry);
			//console.log(timeEntry);
		}
		if(i == 30){
			pageNum++;
			GetNextEntry();
		}
		else{
			FinishUp();
		}
		//response.forEach(element => console.log(element));
	  })
	  .catch(console.error);
}

This is the auth method I am using in 3 other apps as well, though all of those are still working just fine. Does anyone know if something has changed on Freshdesk’s end to do with getting time entries specifically?

Hi @zen.dexter ,

Once try to send the options after stringifying their options.

Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.