Calling to accept/decline returns that the json format is not valid, despite following the documentation:
Below is example code where I placed my own userId, but using users that are pending to join the group has the same response.
From within a server script in Studio:
local function handleGroupRequest(player: Player, shouldAccept: boolean)
if shouldAccept == nil then
warn(string.format("shouldAccept is nil for player %s", player))
return
end
local joinRequestId = player.UserId
local groupId = 6483054
local state = shouldAccept and "accept" or "decline"
local url = string.format(
"https://apis.roblox.com/cloud/v2/groups/%d/join-requests/%d:%s",
groupId,
joinRequestId,
state
)
print("Request URL:", url)
local success, response = pcall(HttpService.RequestAsync, HttpService, {
Url = url,
Method = "POST",
Headers = {
["Content-Type"] = "application/json",
["x-api-key"] = HttpService:GetSecret("TEST_KEY"),
},
Body = HttpService:JSONEncode({})
})
if success and response.Success then
print("The response was successful:", response.StatusCode)
else
warn("The response returned an error:", response)
end
if success and response.Body then
local decoded = HttpService:JSONDecode(response.Body)
print("Response body:\n", printTable(decoded))
end
end
