Reputation: 53
I am getting this error when trying to get info from a dictionary.
#1. What does this error mean? #2. How would I go about fixing it
Here is my current code:
getGroup = requests.get(url = "https://groups.roblox.com/v2/groups?groupIds=" + str(groupId))
req = getGroup.text
print(dict(req)["data"][0])
Error raised:
Command raised an exception: ValueError: dictionary update sequence element #0 has length 1; 2 is required
The info the request gets:
{'data': [{'id': 7850173, 'name': 'Project Studios - Roblox', 'description': 'Happy May! \n\nJoin our Communications server to see the progress on our latest projects. \n\nCheck out my friends groups in the Affiliates tab! \n\nFunny Fortnite?\n\n- Group Description Updated 5-1-21 -', 'owner': {'id': 55065985, 'type': 'User'}, 'memberCount': 428, 'created': '2020-09-24T00:01:23.853Z'}]}
Thanks a lot if you could help!
Upvotes: 0
Views: 1976
Reputation: 5651
You need to convert the json response into a data structure first.
getGroup = requests.get(url = "https://groups.roblox.com/v2/groups?groupIds=" + str(groupId))
req = getGroup.json()
await ctx.send(dict(req)["data"][0])
Upvotes: 1