Sending HTTP request with JSON in body as PUT method

Ok. The first question is how to send data as pure json in body.
All requests we can make now is throw this code (which is written in /lua/includes/modules/http.lua)


local request = 
  {
    url         = "yoururl",
    method      = "POST",
    headers     = {
      ["Content-type"] = "application/json"
    },
    parameters  = {
      test = "true"
    },
    success     = function(code, body, headers)
      print(body)  
    end,
    failed      = function(reason)
    end
  }

  HTTP( request )

See this?



parameters  = {
  test = "true"
}


So your requests will look like:


test=true

But what if I don’t want send key-value data but json like this:


{"test":true}

Can I make request this way? Anybody used to face this thing?

That’s what cURL can do, for example:
First curl is for key-value, second is for json (I need to send data as in the second request)

First request is for json and the second is for key-value.

The second question is why PUT method won’t send any body data (only query data)?
This parameters won’t be shown in request data. I don’t know why. PUT must accept body-data as POST do. But it doesn’t.


 parameters  = {
   test = "true"
},

Should I use another library for networking or I use derfault library incorrectly?

This work?
[lua]
parameters = {
body = [[{“test”:true}]]
}
[/lua]

Thank you for replying.

No, it doesn’t work. Because http library supports only key-value parameters. Probably. That was the question.
Looks like there’s two ways: use another library and wait update that’ll never happen.


body=%7B%22test%22%3Atrue%7D

should be


{"test":true}

Well, I will use this socket library instead.