Hi, I am working with the Fuel API, and been able to attain my access token. However, subsequent calls to get the reference data consistently results in a status 500 error, InternalServerError. Below is the execution to get the reference data from the v1 endpoint.
async function getRefData() {
const now = new Date();
const date = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = String(now.getFullYear());
const hour = String(now.getHours()).padStart(2, '0');
const minute = String(now.getMinutes()).padStart(2, '0');
const second = String(now.getSeconds()).padStart(2, '0');
const timestamp = `${date}/${month}/${year} ${hour == '00' ? '12' : hour}:${minute}:${second} ${parseInt(hour) < 11 ? 'AM' : 'PM'}`;
console.log(timestamp);
const response = await fetch("https://api.onegov.nsw.gov.au/FuelCheckRefData/v1/fuel/lovs", {
"method": "GET",
"headers": {
"content-type": "application/json; charset=utf-8",
"authorization": `Bearer ${process.env.ACCESS_TOKEN}`,
"apikey": process.env.API_KEY,
"transactionid": crypto.randomUUID(),
"requesttimestamp": timestamp
}
});
const status = response.status;
console.log(`Ref resp status = ${status}`);
const body = await response.json();
console.log(`Returned ref data =`);
console.log(body);
}
await getRefData();
The result is
Returned ref data =
[object Object]
{
errorDetails: {
code: 'InternalServerError',
message: 'Error occurred while handling the request'
}
}
Have followed the code examples but consistently receive an InternalServerError.