Can I post to http in Codea?

Is there some sort of way? For what I’m working on its important that I can. I know you can request things using http.request FYI

Yup. Here’s a function I use in some of my code, showing both the call and how to pass the POSTed data:

function post(data, success, fail)
    if (sid) then data["sid"]=sid end
    local dstring = ""
    local k,v
    for k,v in pairs(data) do
        if (dstring == "") then
           dstring = k .. "=" .. v
            dstring = dstring .. "&" .. k .. "=" .. v
   -- print(dstring)
    local t = { ["method"]="POST", ["data"]=dstring }
    http.request(url, success, fail, t)

To use, I’ll do something like:

post({["name"] = "Tom", ["age"] = "46", ["awesomeness"] = "the max"}, successfunction, failfunction)

and set up appropriate functions to handle success or failure. (I think this is why http.get got renamed to http.request - it can do any method…)


Ohhhhhhh so http.request is post and get combined

Now it makes sense

Yep. You can, in theory, override it with any of the http methods (DELETE, PUT, HEAD, etc), but I haven’t tested that.