PUT on restdb.io

Hello, I’m using Corona SDK (Lua Programming ) to make a PUT request to my restdb.io (www.restdb.io) in according with Corona network.request method (https://docs.coronalabs.com/api/library/network/request.html) and restdb.io documentation (www.restdb.io)

The GET request is OK but the PUT (or POST) seems to have no effect in my DB.

This is the code. I tried body as string and body as file.

– Body as string

myURL = “https://mydbname.restdb.io/rest/comuni/ID” (where ID is _id field value of my record)
headers[“Content-Type”] = “application/json”
headers[“X-API-Key”] = “myapi”
local body = “{“myfield”:“new_value”}”
params.body = body
network.request( URL, “PUT”, restPUT, params )

Body as file

myURL = “https://mydbname.restdb.io/rest/comuni/ID

headers[“Content-Type”] = “application/json”

headers[“X-API-Key”] = “myapi”

params.body = {
filename = “myjson.file”
}
network.request( URL, “PUT”, restPUT, params )
(binary mode for body has no effect)

local function restPUT( event )
if ( event.isError ) then
print( "Network error: ", event.response )
else
print ( “Upload complete!” )
end

With google firebase i have no problems with PUT, GET, POST and DELETE, but i would like to use restdb.io

Can you help me ? Thanks 

Andrea Malatesta

Hi, 

the apikey header field should be “x-apikey” and not “X-API-Key”.

Yes, thanks. i resolved yesterday. It was an old script for firebaseio. You are a very observer. Best regards  

Hi, 

the apikey header field should be “x-apikey” and not “X-API-Key”.

Yes, thanks. i resolved yesterday. It was an old script for firebaseio. You are a very observer. Best regards