Showing results for 
Show  only  | Search instead for 
Did you mean: 

rumUserSessionsClient API error in AUTH


Hi all,

I'm developing a dynatrace app and I would like to get the data for the user session query API as I have always done from Postman 

From the documentation I have seen that the portion of the code needed to fetch the data of user session query is this:


import { rumUserSessionsClient } from "@dynatrace-sdk/client-classic-environment-v1"

export default async function fetchDataUserSession() {
const response = await rumUserSessionsClient.getUsqlResultAsTable({
  query: "SELECT * FROM usersession",
  startTimestamp: 0 ,
  endTimestamp: 0,
  pageOffset: 0



but whenever I call this method I get this error:

Request failed: {"code":403,"message":"OAuth token is missing required scope. Use one of: [environment-api:usersessionquerylanguage:read]"}

In the previous version of dynatrace I used to create an API token and put it on the header of the HTTP call to dynatrace.

In another application, I used to call the dynatrace user session query:


def callDynatrace(startDate,endDate,query,token,mainUrl ):
    query_params = {
      "query": query,
      "startTimestamp": date_to_milliseconds(startDate),
      "endTimestamp": date_to_milliseconds(endDate),
      "explain": False
    headers = {
      "accept": "application/json",
      "Authorization": "Api-Token " + token


 In this new version of dynatrace, it seems that the authentication method has been changed... especially in the developement of the app.

Thank you in advance,



DynaMight Legend
DynaMight Legend

easy fix, your token dosnt have the needed read access. Go back in t your Dynatrace UI and make a new tokens with the access as defined in the error message. Existing tokens you cant add permissions to, so tokens and permissions will always be net new FYI. 


Featured Posts