Messaging service api always returns <RESPONSE 401>


Basically, whenever I try to send an request to the messaging service api, it will always return response 401. And yes I checked many times and the key is valid. I keep getting this error and I dont know how to fix it.
here is the code.

def buttonCallback():
    headers = {
      'x-api-key': '?'
    }
    json_data = {
       'message': textbox.get("1.0", END),
    }
    response = requests.post(url, headers=headers, json=json_data)
    print(response)

Yes the messaging service code while running works.

Im trying to make some app where it will do a global message if your wondering. Thanks

1 Like

image
My first guess is the key system is broken. I kept regenerating it and putting it in the script and testing with postman, it never works.

1 Like

Have you tried including 'Content-Type': 'application/json' in the headers?

1 Like

in python we dont do that with caps

and its optional and i already tried it

1 Like

It’s telling you your api key is wrong so are you sure you’re sending it correctly?

1 Like

Yes I am. And I checked the api key many times and its the exact same as the api key i copied.

1 Like

Oh I didnt know it was optional. Do you have the Messaging Service API added on the creator dashboard?

2 Likes

Yeah, and added the experience to the creator dashboard

1 Like

Have you allowed “publish” as an experience operation?

1 Like

yes i did all of this. and even allow any ip addresses etc.

1 Like

Okay well I’ve just tried it out and it seems to be working for me so I highly doubt it’s an issue with the API itself.

This is the code I used to try it out

import requests

universe_id = 3702278406
api_key = #### Redacted


url_format = "https://apis.roblox.com/messaging-service/v1/universes/{universeId}/topics/{topic}"

def main():

    url = url_format.format(universeId = universe_id, topic = "test")

    response = requests.post(
        url,
        headers = {
            "x-api-key": api_key
        },
        json = {
        "message": "hello"
        })
    
    print(response)

if __name__ == "__main__":
    main()
2 Likes

ill try this when I am at my computer, If it works ill mark it as a solution!

1 Like


same error, ik im late

1 Like

What is the body of the response and what headers does it return?

1 Like

actually let me see. give me one second

1 Like

I think this does just prove it’s an api key issue though so I’d go through and make sure everything is exactly right.

1 Like

1 Like

when i made the ip for everyone,it returns me this
image

1 Like

So there is some kind of extra access you need to give to the api key.

1 Like

idk. but what is the extra access you are taking about?

1 Like