while calling the Timeseries Insights API from Nodejs I get a 500 internal server error every time I do a request. For example:
const res = await getToken(
'https://login.microsoftonline.com/',
process.env.TENANT_ID,
'https://api.timeseries.azure.com/',
process.env.CLIENT_ID,
process.env.CLIENT_SECRET
);
const token = res.data.access_token;
const result = await axios.post(
`https://${process.env.TIME_SERIES_INSIGHTS_FQDN}/events?api-version=2016-12-12`,
{
searchSpan: {
from: {
dateTime: moment()
.subtract(1, 'day')
.startOf('day')
.format(),
},
to: {
dateTime: moment()
.subtract(1, 'day')
.endOf('day')
.format(),
},
},
breaks: {
count: 1000
},
},
{
headers: {
Authorization: `Bearer ${token}`,
},
}
);
return result;
The getToken function returns a valid access token that is authorized to call the Timeseries API. I know this because before this problem, I didn't get a valid token and I received a more descriptive error about the token not being valid.
As far as I know, the request parameters are all correct. According to the API docs, searchSpan
and the limit clause (breaks
) are mandatory parameters.
I get the same error from Postman.
The 500 Internal Server error response is not very descriptive so I'm kind of stuck. Does anyone know if this might still be an authorization problem or is my request structure wrong?