Messaging Service API Link

I need the link for the API itself to interact with my JavaScript code. Not the docs.

You could’ve been a bit more clearer then

My apologies. Will edit post now.

You won’t be able to use MessagingService for that, you would need to use HTTPService if you want to communicate data from an external source.

Yes, but I need messaging service for my integration to send stuff to ROBLOX. Right now I’ve integrated a ban system using my external DB with HTTPService, but I need to use MessagingService for another piece.

MessagingService is just for sending information between servers within a game. An external database would still need to use HTTPService.

I don’t think you’re getting where I’m coming from. I’m sending a request to messaging service API to interact with servers in the game, using an external integration. ROBLOX has an API for this, and I need to link to use it.

Oh sorry, is it not the same as this MessagingService | Roblox Creator Documentation?

Found a link from LifeDigger’s Community Resource tutorial, not sure if its what you want or will help but its worth a try sending it anyway

1 Like

It’s using MessagingService but from a 3rd party basically.

My Integration -> Requests MessagingService Request -> Roblox sees it and publishes to all servers
1 Like

Thanks! Should work out for me!

2 Likes

no worries, did you figure it out after?

No. This is my code:

      let res = await fetch("https://apis.roblox.com/messaging-service/v1/universes/4313843182/topics/Kick", {
        method : "Post",
        headers : {
          ["x-api-key"] : "NOT_MY_API_KEY",
        },
        body : { message : userid + ":::" + reason }
      })

Says unsupported media type.

1 Like

You need to specify the Content-Type header as application/json.

headers: {
    ["Content-Type"]: "application/json",
    ["x-api-key"]: "NOT_MY_API_KEY",
},

Content-Type (also called media type) tells the server what type of content you’re sending, I believe it defaults to plain text which is unsupported.
If you need more information on how to send using this API, this part of the documentation explains more about how to message live servers.

1 Like

Part of the issue is what @Shirovian said (it should fix the media issue), unlike some packages likes axios (which should work fine without the content type) it seems like fetch does not automatically set the correct content type or something like that.

The other problem will occur when you try send the request with the content type set where it will say the request was a “Bad Request”. This seems to be caused in the body and should be fixed by just doing something like below. For some reason fetch also does not automatically send it correctly when you set the request like you have so rather then what you have done, you need to turn it to a string with JSON.stringify().

image

1 Like

It now sends status code 200, but nothing happens in game with this function:

messageservice:SubscribeAsync("Kick", function(data)
	local kickNameReason = data.Data;
	kickNameReason = string.split(kickNameReason, ":::");
	print(data)
	if game.Players:FindFirstChild(kickNameReason[1]) then
		local player = game.Players:FindFirstChild(kickNameReason[1]);
		player:Kick(kickNameReason[2]);
	end
end)

type: ‘default’,
url: ‘https://apis.roblox.com/messaging-service/v1/universes/4313843182/topics/Kick’,
status: 200,
statusText: ‘OK’,

1 Like

Fixed, figured out you can’t use this in studio. :facepalm:

1 Like

Yea it does not work in-studio (I think that it is cuz it fires to all Roblox servers and when you test in-studio it is locally ran or something like that). Don’t worry your not the first one who has made that mistake, other people have asked me the exact same thing and it was cuz they where in-studio.

Ah okay, I’m quite new to this API stuff. The most I have is a integration to ban people from outside of ROBLOX, and check my database. However, I’ve never actually sent to roblox before so it’s weird haha. Thanks alot for your help!!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.