network request to back4app

Hi, I am trying to send the following cURL using network.request but I always get error, can you pls send me how to send this request using network.request.

same command is working from MAC terminal

curl -X GET \

-H “X-Parse-Application-Id: b6rnGc4XpuC8NCMP8hKbz4oDG3QuZZz06w1FeDXi” \

-H “X-Parse-REST-API-Key: UDGuerOe0TntbXB0J18U5HxQrtUucT1npluvfJmw” \

-H “X-Parse-Revocable-Session: 1” \

-G --data-urlencode ‘username=ashraf’ \

–data-urlencode ‘password=aa’ \

https://parseapi.back4app.com/login

 

Thank you

Hi,

You should be able to do it like so:

local url = require("socket.url") local function onRequest(event) if ( event.isError ) then print( "Network error: ", event.response ) else print ( "RESPONSE: " .. event.response ) end end local params = { headers = { ["X-Parse-Application-Id"] = "b6rnGc4XpuC8NCMP8hKbz4oDG3QuZZz06w1FeDXi", ["X-Parse-REST-API-Key"] = "UDGuerOe0TntbXB0J18U5HxQrtUucT1npluvfJmw", ["X-Parse-Revocable-Session"] = "1" } } local username = url.escape("ashraf") local password = url.escape("aa") local query = string.format("username=%s&password=%s", username, password) local uri\_path = "https://parseapi.back4app.com/login?"..query network.request( uri\_path, "GET", onRequest, params )

Hope that helps.

-dev

Hi,

Thank you for your support.

For years I used your great mod_parse, and parse plugin, but currently it is not working with back4appm this is why I am trying to use my old code and change the mod_parse calling to network REST API calling.

What about other functions, like class queue with complicated where? os there any samples or reference on how to translate CURL to coronasdk.

Thank you so much for your support.

Hi,

You should be able to do it like so:

local url = require("socket.url") local function onRequest(event) if ( event.isError ) then print( "Network error: ", event.response ) else print ( "RESPONSE: " .. event.response ) end end local params = { headers = { ["X-Parse-Application-Id"] = "b6rnGc4XpuC8NCMP8hKbz4oDG3QuZZz06w1FeDXi", ["X-Parse-REST-API-Key"] = "UDGuerOe0TntbXB0J18U5HxQrtUucT1npluvfJmw", ["X-Parse-Revocable-Session"] = "1" } } local username = url.escape("ashraf") local password = url.escape("aa") local query = string.format("username=%s&password=%s", username, password) local uri\_path = "https://parseapi.back4app.com/login?"..query network.request( uri\_path, "GET", onRequest, params )

Hope that helps.

-dev

Hi,

Thank you for your support.

For years I used your great mod_parse, and parse plugin, but currently it is not working with back4appm this is why I am trying to use my old code and change the mod_parse calling to network REST API calling.

What about other functions, like class queue with complicated where? os there any samples or reference on how to translate CURL to coronasdk.

Thank you so much for your support.