Hi,
I am trying to get user ids based on DIVISION.
Could you please let me know which API I can use to get user ids based on DIVISION ?
Thanks..!!
Regards,
Suresh U
Hi,
I am trying to get user ids based on DIVISION.
Could you please let me know which API I can use to get user ids based on DIVISION ?
Thanks..!!
Regards,
Suresh U
Hi Suresh,
Currently, division id is not a field you can directly search on our Users API. What you would need to do is call the GET /API/v2/users endpoint. This will return a query set of all the users. Remember, the query set is paginated so you might need to make multiple calls asking the API to return each page.
With each page, you would need to check the division JSON block on the record and see if it matches the division that you are looking for.
Thanks,
John Carnell
Manager, Developer Engagement
Hi John,
Thanks for your reply..!!
I have got the users ids and trying to set acdautoanswer to 'true' these users. I have prepared a data frame with "userid" and "acdautoanswer". I am converting to Json object before sending it to patch_users_bulk API in python. But I am getting bad request error. Could you please help what I am missing ?
df_selected_userids = rows[['id','acdAutoAnswer']]
json_body = df_selected_userids.to_json(orient="records")
print('body :='+json_body)
users_api = PureCloudPlatformClientV2.UsersApi(apiClient)
users_api.patch_users_bulk(json_body)
Hi Suresh,
Can you post what your JSON array looks like. This looks like this should work. I would also recommend that you use our API explorer in our Dev Tools. This will allow you to call the API directly without the code and can often help you figure out the payload issues. Also, if you make the call in our API explorer, you can see a inin-correlation-id. If you post that in the chat, I can check our logs and see if there is anymore detail.
Thanks,
John
Hi John,
Here is my Json body :=
[{"id":"xxxxxxx-xxxxxxxxx","acdAutoAnswer":false},{"id":"xxxxxxx-xxxxxxxxx","acdAutoAnswer":false},{"id":"xxxxxxx-xxxxxxxxx","acdAutoAnswer":false}] .
It works from Developer tools but not from the script. I have to update the autoanswer flag for 100s of users. So trying to get it from script. I am pasting my complete method here for your reference. Thanks ..!!
def process_json(apiClient, results):
try:
df_user_ids = json_normalize(results['entities'], meta=['id', 'name', 'username', 'state'], errors='ignore')
df_user_ids = df_user_ids[['id', 'name', 'username', 'division.id', 'state']].copy()
df_user_ids['acdAutoAnswer'] = False;
cond = (df_user_ids['division.id'] == 'XXXXXXXXXXXXXXXXXXXX')
rows = df_user_ids.loc[cond, :]
df_selected_userids = rows[['id','acdAutoAnswer']]
json_body = df_selected_userids.to_json(orient="records")
print('body :='+json_body)
users_api = PureCloudPlatformClientV2.UsersApi(apiClient)
users_api.patch_users_bulk(json_body)
Let me know if you need any additional details. Thanks..!!
Regards,
Suresh U
Hello Suresh,
I don't have much experience on python (shame on me ) but I tried to debug a small piece of code.
I believe (quite sure) that your problem is coming from the fact that the body is expected to be a list (variable of type list).
The to_json(orient="records") in fact produces a string.
So json_body is in fact '[{...},{...}]'
Regards,
Hi Jerome,
Thanks for checking this. I have only this option to convert data frame into required json format. So I have used it. But same Json response result works in developer tools but not from the code.
I have tried from Java but it works fine without any issue. I am sure missing something but not sure what is missing
Thanks..!!
Hi Jereme,
Please ignore my previous comment. You are correct I have changed String to Python object before sending it to API. It worked. Thanks for your help..!!
json_body = df_selected_userids.to_json(orient="records")
print('body :='+json_body)
y = json.loads(json_body)
users_api = PureCloudPlatformClientV2.UsersApi(apiClient)
users_api.patch_users_bulk(y)
Regards,
Suresh U
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.