I am building a project that uses xbox-webapi and I need to find out the format for the xuid messaging here is my code for the auth script
<code>async def send_message(auth_mgr, recipient_xuid, message_text, client_session):
xbl_client = XboxLiveClient(auth_mgr=auth_mgr)
try:
formatted_xuid = "["+recipient_xuid+"]"
print(formatted_xuid)
await xbl_client.message.send_message(
xuid=recipient_xuid,
message_text=message_text
)
print(f"Message sent to XUID {recipient_xuid}: {message_text}")
except Exception as e:
traceback.print_exc()
print(f"Failed to send message: {e}")
</code>
<code>async def send_message(auth_mgr, recipient_xuid, message_text, client_session):
xbl_client = XboxLiveClient(auth_mgr=auth_mgr)
try:
formatted_xuid = "["+recipient_xuid+"]"
print(formatted_xuid)
await xbl_client.message.send_message(
xuid=recipient_xuid,
message_text=message_text
)
print(f"Message sent to XUID {recipient_xuid}: {message_text}")
except Exception as e:
traceback.print_exc()
print(f"Failed to send message: {e}")
</code>
async def send_message(auth_mgr, recipient_xuid, message_text, client_session):
xbl_client = XboxLiveClient(auth_mgr=auth_mgr)
try:
formatted_xuid = "["+recipient_xuid+"]"
print(formatted_xuid)
await xbl_client.message.send_message(
xuid=recipient_xuid,
message_text=message_text
)
print(f"Message sent to XUID {recipient_xuid}: {message_text}")
except Exception as e:
traceback.print_exc()
print(f"Failed to send message: {e}")
But keep on getting this error:
<code>Traceback (most recent call last):
File "/Users/######/Desktop/######/Project Xetram/xbox_messaging_debug.py", line 50, in send_message
await xbl_client.message.send_message(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/xbox/webapi/api/provider/message/__init__.py", line 133, in send_message
resp.raise_for_status()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://xblmessaging.xboxlive.com/network/Xbox/users/me/conversations/users/xuid(######)'
</code>
<code>Traceback (most recent call last):
File "/Users/######/Desktop/######/Project Xetram/xbox_messaging_debug.py", line 50, in send_message
await xbl_client.message.send_message(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/xbox/webapi/api/provider/message/__init__.py", line 133, in send_message
resp.raise_for_status()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://xblmessaging.xboxlive.com/network/Xbox/users/me/conversations/users/xuid(######)'
</code>
Traceback (most recent call last):
File "/Users/######/Desktop/######/Project Xetram/xbox_messaging_debug.py", line 50, in send_message
await xbl_client.message.send_message(
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/xbox/webapi/api/provider/message/__init__.py", line 133, in send_message
resp.raise_for_status()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://xblmessaging.xboxlive.com/network/Xbox/users/me/conversations/users/xuid(######)'
I dont know if there is a correct format for the script or its just the apipremissions for my application is not set.
I expected it to send my message to my xbox account but its not working
New contributor
Mark Lopez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.