How to invoke Rest API in prosody

I need to make a REST API call when user leaves the meeting.

API to be added in speaker_stats in /usr/share/jitsi-meet/prosody-plugins/ext_events.lib.lua.

Code Tried:
local h = require “socket.http”
local ltn12 = require(“ltn12”)
local payload = [[ {“meetingId”:*********} ]]
local response_body = {}

local res,code,headers,status =
h.request{
method = “POST” ,
url = "https://**.execute-api.us-east-1.amazonaws.com/NonProd/grantModeratorDelete",
headers = {[“Content-Type”] = “application/json”},
body = {“meetingId”:
}
}
print (code, headers, status)

Issues:
Got 307 redirect when tried in local.
Not able to install luasocket in server.

Please also suggest any alternate techniques to call API.

Thanks.

There already exists a complete example of using Rest with Prosody in Jitsi-meet code, how about reading it and take ideas from it ?

Take a look at this:

If it does not suit your requirements, the code might serve as a guide on how to write your own.