Admin V2 API Troubleshooting

Hello dear community!

When trying to use the Admin V2 API list-users endpoint, I’ve been facing some major issues. Since it’s currently on a preview, it can be accessed strictly with the preview=true argument, otherwise it throws the following error:

ApiFeaturePreviewUsageOnly INVALID_ARGUMENT 400 The given API endpoint is not for production use and is only supported in preview mode. Please add a preview=true query parameter to call this endpoint.

Whenever preview=true is added, the following error message is thrown in the API response:

Conjure:InvalidArgument INVALID_ARGUMENT 400 One or more of the request’s arguments is invalid.

This is the code being used for this specific trial:

import requests

HOSTNAME = ‘host’

TOKEN = ‘mytoken’

headers = { “authorization”: “Bearer {}”.format(TOKEN), “Content-Type”: “application/json” }

url = ‘https://{}/api/v2/admin/users?pageSize=100&preview=true’.format(HOSTNAME) response = requests.get(url, headers=headers) print(“Response Content:”, response.json())


We were referencing from this documentation: https://www.palantir.com/docs/foundry/api/admin-v2-resources/users/list-users/#request https://www.palantir.com/docs/foundry/api/general/overview/errors/

So, from the docs, one of the possibilities is that maybe our account, authenticated via OAuth2, doesn’t have the following operation scope enabled: “api:admin-read”. Could this be the issue for such message? I wonder the issue should be related to permissions and not the InvalidArgument.

Did any of you have the opportunity to use this specific API endpoint successfully? If yes, could you please give me some insights regarding the usage? If you faced similar issues, did you find a solution to them?

Thank you all a lot for your support!

Hi,

A 400 is a bad request and your code snippet looks a bit off. Try something like the below:

import requests

HOSTNAME = 'host'
TOKEN = 'mytoken'

headers = {
    "authorization": "Bearer {}".format(TOKEN),
    "Content-Type": "application/json"
}

url = 'https://{}/api/v2/admin/users?pageSize=100&preview=true'.format(HOSTNAME)
response = requests.get(url, headers=headers)
print("Response Content:", response.json())