Parse Cloud Code Question

jonwrig

New Member
Licensed User
Longtime User
I tried the Parse B4A module example and it works great.

But I want to run some logic on Parse.com using their Cloud Code and they say the way you call it is using HTTP POST - unfortunately I cannot find any examples of this.

I started with calling a simple "Hello World" function I created but all I'm getting back is the response "Unauthorized". Does anyone have any knowledge on this? What am I doing wrong?

Here is my code:

Dim hj As HttpJob
hj.Initialize("HelloJob", Me)
hj.GetRequest.InitializePost2("https://api.parse.com/1/functions/hello", "".GetBytes("UTF-8"))
hj.GetRequest.SetHeader("X-Parse-Application-Id", myappkey)
hj.GetRequest.SetHeader("X-Parse-REST-API-Key", myapikey)
hj.GetRequest.SetContentType("application/json")
hj.PostString("https://api.parse.com/1/functions/hello", "")

Thanks in advance!
 

jonwrig

New Member
Licensed User
Longtime User
Fixed - thanks for the tip

The solution was simply to move the PostString infront of the SetHeaders

Dim hj As HttpJob
hj.Initialize("HelloJob", Me)
hj.PostString("https://api.parse.com/1/functions/hello", "{}")
hj.GetRequest.InitializePost2("https://api.parse.com/1/functions/hello", "{}".GetBytes("UTF-8"))
hj.GetRequest.SetHeader("X-Parse-Application-Id", myappkey)
hj.GetRequest.SetHeader("X-Parse-REST-API-Key", myapikey)
hj.GetRequest.SetContentType("application/json")


Response String:
{"result":"Hello World!"}

This is great because now I can do more complex logic with sets of Parse objects serverside using a javascript function and then return the result as JSON to B4A for client processing

Mart
 
Upvote 0
Top