0

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?

Ventis
  • 488
  • 6
  • 22
  • You are getting 500 internal server error means code is breaking, please check the data you are passing to the time API. – Rahul Rana Jul 10 '19 at 12:47
  • @RahulRana If I do a simple test and pass the following to the API I still get the error. Even though this is copied almost directly from the API reference docs: { "searchSpan": { "from": { "dateTime": "2019-07-09T00:00:00.000Z" }, "to": { "dateTime": "2019-07-10T00:00:00.000Z" } }, "take": 10 } – Ventis Jul 10 '19 at 13:10
  • Then might be the api is not working, its down – Rahul Rana Jul 10 '19 at 13:12

1 Answers1

0

The API is up. I found out though that the preview API is totally different from the GA API. And that our TSI instance is running in preview mode ...

Ventis
  • 488
  • 6
  • 22