I want make POST request to parse.com for object creation. This is my code:
sk=net.createConnection(net.TCP, 0)
addr=""
sk:dns("api.parse.com",function(conn,ip) addr=ip end)
print(addr)
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload) print(payload) end )
conn:on("connection", function(c)
conn:send("POST /1/classes/TestClass2 HTTP/1.1\r\n"
.."Host: api.parse.com\r\n"
.."X-Parse-Application-Id: 1***whq****************oJFzu43nIO**rzh\r\n"
.."X-Parse-REST-API-Key: 6Y***QPSQ****************bgzIhxYqG**OsfY\r\n"
.."Content-Type: application/json\r\n"
.."Connection: keep-alive\r\nAccept: */*\r\n\r\n")
end)
conn:connect(80, addr)
I try connecting with different combination of headers but every time I get 401 ERROR
HTTP/1.1 401 Unauthorized
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Date: Sat, 31 Oct 2015 18:05:11 GMT
Server: nginx/1.6.0
Www-Authenticate: Basic realm="Parse"
X-Parse-Platform: G1
X-Runtime: 0.015377
Content-Length: 25
Connection: keep-alive
{"error":"unauthorized"}
Does some one use parse with node mcu? Where could my problem be?
P.S: Initial working request I get from postman.