Forum Discussion
3 Replies
Sort By
- Hoekstra_VFZ3 years agoAdvisor
Yeah, the role is not in users but in roles:
SELECT name FROM roles WHERE users.id = ''I have made a component that displays the role as well the rank in the avatar section of a message. For non-admin users to see the role, it was needed to perform above query using restadmin instead rest.
- Akenefick3 years agoGenius
I think you can use a Json subquery The Community API v2 request (khoros.com) to get the roles too while still making only one API request. I've had to do something similar to get labels for messages.
- keithkelly3 years agoLeader
Holy **bleep** it worked!
Here's a simple working Python script:
import json import requests headers = { "li-api-session-key": "XXX", "Content-Type": "application/json" } data = { "users": { "fields": ["login","roles"], "constraints": [], "subQueries": { "roles": { "fields": ["id", "name"], "limit": 20 } } } } response = requests.post("https://[your community]/api/2.0/search", headers=headers, json=data) print(response.json())
I'm looking forward to tweaking it a bit and using this in Excel or PowerBI PowerQuery. Thanks!
Related Content
- 3 years ago