Hi, I’m working on a REST API where I use the methods PUT and DELETE to update or delete a objects created in the server end.
What I discovered after a couple of hours of debugging is that http.request sends out a empty body request when using a “PUT” method. I’ve tried the same with curl and php and there it works as it should. I’ve also tried to replicated the headers sent out by the curl request and used it in the Defold http.request, but this didn’t help either.
This works:
headers = {}
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Accept"] = "*/*"
request_body = tools.json_encode({["test"] = "value"})
http.request("http://localhost:80/index", "POST", function(self, id, response)
pprint(response)
end, headers, request_body)
But this doesn’t:
headers = {}
headers["Content-Type"] = "application/x-www-form-urlencoded"
headers["Accept"] = "*/*"
request_body = tools.json_encode({["test"] = "value"})
http.request("http://localhost:80/index", "PUT", function(self, id, response)
pprint(response)
end, headers, request_body)
…and the only difference is the request method.
Any ideas on how to solve it?
Thanks