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

Error calling API Settings in App

joseafcampos
Participant

I'm testing a dynatrace App in React. I've a hook that is calling Settings API through TypeScript SDK as you can see on the code snippet:

 

try {
      var config = {"schemaIds":"builtin:alerting.maintenance-window",
                    "scopes":"environment"}
      const response = await settingsObjectsClient.getSettingsObjects(config);
      console.log(response);
...
    } catch (e) {
...
    }
 
But I get the following error in the browser:
SyntaxError: Unexpected token 'O', "OAuth token"... is not valid JSON
at JSON.parse (<anonymous>)
at fetchQuery (http://localhost:3002/ui/main.js:123265:36)
 
And  in the console I have this message:
Request failed: {"code":403,"message":"OAuth token is missing required scope. Use one of: [settings:objects:read]"}
 
I've executed the same code in a notebook and there was no problem. So It seams that when I call the same API from React APP, the typescript SDK is not passing the login user authorization token.
 
 
 
2 REPLIES 2

stefan_eggersto
Dynatrace Mentor
Dynatrace Mentor

Hi @joseafcampos ,

to access the Settings API from your app, you need to add the scope settings:objects:read to your app config file. You can find the instructions at https://developer.dynatrace.com/develop/security/add-scopes/

Thank you, that fixed the problem.

Featured Posts