Problems with GET /api/v2/authorization/subjects/{subjectId}

Hello,

I want to use the JS SDK to get the grants informations using GET /api/v2/authorization/subjects/{subjectId}.
I couldn't get this informations. I tested it with one subjectId. This Id works for the API-Explorer, but doesn't works for the JS SDK version. The console log is also strange:

""body": {
"id": "[object object]",
"grants": [],
"version": 1,
"selfUri": "/api/v2/authorization/subjects/%5Bobject%20object%5D"
},
"error": null

Below is a snippet of the used source code (purecloud-platform-client-v2 version - 188.1.0):

const platformClient = require('purecloud-platform-client-v2');
const gcApiClient = platformClient.ApiClient.instance;
const environment = platformClient.PureCloudRegionHosts.eu_central_1;

let clientId = xxxx;
let clientSecret = xxxx;
...
client.loginClientCredentialsGrant(clientId, clientSecret)
.then((response) => {
console.log('GC Logged in sucessfully: ' + JSON.stringify(response, null));
}).catch((ex) => {
console.error('Exception during login: ' + JSON.stringify(ex, null, 2));

});

...
let apiInstance = new platformClient.UsersApi();
let userId = xxxx;
apiInstance.getAuthorizationSubject(platformClient, userId)
.then((data) => {
console.log(getAuthorizationSubject success! data: ${JSON.stringify(data, null, 2)});
})
.catch((err) => {
console.log("There was a failure calling getAuthorizationSubject");
console.error(err);
});

Could you explain how to solve this error?

Best regards,
Marcel

Hello,

You're passing a wrong/extra parameter (platformClient) in your call to getAuthorizationSubject method
There is a single param (the subjectId) - in your case: `apiInstance.getAuthorizationSubject(userId)``

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.