Marcel_Grafenstein | 2024-02-26 12:47:36 UTC | #1
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.eucentral1;
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
Jerome.Saint-Marc | 2024-02-26 13:03:03 UTC | #2
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,
system | 2024-03-28 13:03:56 UTC | #3
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 24872