带Lua的HTTP帖子

时间:2017-05-01 15:13:25

标签: rest lua nodemcu

我是Lua世界的新人。我想通过RESTApi从NodeMCU发送数据,我收到错误。你能告诉我我写错了吗

function func_http_post()
print("sending data")
body= '{"mode":"sync","messageType":"f15a15604014bb5f0ec0","messages":[{"sensor":"sensor1","value":"11","timestamp":1413191656}]}'
http.post('URL',
    'Content-Type: application/json\r\n'
  ..'Authorization: Bearer 363f74ab6fdf5dda293d2f16e7a5ac\r\n',
  body,
  function(code, data)
    if (code < 0) then
      print("HTTP request failed")
       print(code, data)
    else
      print(code, data)
    end
  end)
end

这是输出:

sending data
HTTP request failed
-1 nil

提前致谢

0 个答案:

没有答案