azure-signalr icon indicating copy to clipboard operation
azure-signalr copied to clipboard

Getting 401 While sending messages to Specific Connection in REST API

Open DilLip-Chowdary-Codes opened this issue 8 months ago • 2 comments

Describe the bug

While we're trying to send a message to specific connectionId, we're receiving the 401 status code

More Details:

Code:

FYI Access token was generated using the SignalR Serverless Quick start with python

    import requests
    import json

    name = "Dillip"

    connection_id = "g9.....rQw02"

    token = "eyJh....-wH6nA8"

    headers = {
        "Authorization": f"Bearer {token}",
        'Content-Type': 'application/json',
    }

    body = {
        'target': 'newMessage',
        'arguments': [ f"Update Name was as {name}" ]
    }

    response = requests.post(
       f"https://<our-service>.service.signalr.net/api/v1/hubs/<hub_name>/connections/{connection_id}",
        json=body,
        headers=headers
    )

    print(response.content, response.status_code)

Exceptions (if any)

We're getting b'' as API response and 401 as status code.

Further technical details

REST API Version: V1

### Tasks

DilLip-Chowdary-Codes avatar Jun 06 '24 06:06 DilLip-Chowdary-Codes