JavaScript and python users Examples not working

import PureCloudPlatformClientV2

PureCloudPlatformClientV2.configuration.access_token = 'dont post access tokens on the forum! Handle them like passwords!'

api = PureCloudPlatformClientV2.UsersApi()

expand = ["authorization"];

id = [];

pageNumber = 1;

pageSize = 25;

sortOrder = "ASC";

state = "active";

 

result = api.get_users(expand, id, pageNumber, pageSize, sortOrder, state)

print (result)

i use the code above and i get this error

result = api.get_users(expand, id, pageNumber, pageSize, sortOrder, state)
TypeError: get_users() takes 1 positional argument but 7 were given

and in JavaScript it just ignore all the arguments and it gets the default api.getUsers()
what am i missing ???

Are you using the latest version of the Python SDK? I tested the example for UsersApi.get_users(...) shown in the docs and it works fine using the latest Python SDK (v43.0.0). Can you try using the example there as its written? There are a few differences from the code you wrote.

i used the same exact example and i got same error

So i am using python 3.7 and i did pip install PureCloudPlatformClientV2 which i assume that would be the latest SDK

please advise

Are you sure you used the example exactly as it is on the page? It works the way it's written. I can reproduce your error by changing this:

api_response = api_instance.get_users(page_size=page_size, page_number=page_number, id=id, sort_order=sort_order, expand=expand, state=state)

to this:

api_response = api_instance.get_users(page_size, page_number, id, sort_order, expand, state)

The API functions use **kwargs, which require keyworded arguments. If that doesn't work, please post your latest code.

Edit: forgo to mention, if you're also having issues with the JavaScript SDK, please create a new topic with your issue in the JavaScript SDK category.

i am using the same code above ^

from https://developer.mypurecloud.com/api/rest/v2/users/

That code is incorrect. Please use the example I linked.

Thanks for showing me where you got the bad code from. I'll create an issue to get that fixed.

well thank you i will try your code now then i will let you know

btw it's the same issue with Javascript Example as well

1 Like

i tried the example you sent and got this error
again get_users() without it pull all data but once i use **kwargs i get the issues


please advise

You specified an ID filter with no values. Getting a 404 not found from that request is normal. Try not providing the ID filter if you aren't wanting to retrieve specific users by ID.

it works like a charm
Thank you Tim!

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