OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
175 stars 44 forks source link

I keep on getting this error on XboxLiveClient.send_message() #107

Open mas6y6 opened 2 weeks ago

mas6y6 commented 2 weeks ago

I don't know how to format the messages and I keep getting this error

Here is my code for the sending script:

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 annoying error

Traceback (most recent call last):
  File "/Users/*****/Desktop/Python projects/*****/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(*****)'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
Failed to send message: Client error '400 Bad Request' for url 'https://xblmessaging.xboxlive.com/network/Xbox/users/me/conversations/users/xuid(*****)'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

I dont know if there is a format for the xuid that I need or something else...

mas6y6 commented 2 weeks ago

I added a print script and i got this as the result

{"errorCode":400,"errorMessage":"Failed to parse user identity from path."}