Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse-server cloud code function 'Cannot POST'

Most parts of my migration to open source parse-server are successful, with my data correctly stored, accessible.

I am however having problems with cloud code, specifically with running simple curl tests.

The initial parse-server installation includes a sample main.js file that contains a hello world function

My own parse installation is hosted at '/parse' so URLs use this as the root

The following is a simple request test

 curl -X POST \   
 -H "X-Parse-Application-Id: myAppId" \   
 -H "X-Parse-REST-API-Key:myRESTKey" \   
 -H "Content-Type: application/json" \   
 -d '{}' \  
 http://localhost:1337/parse/1/functions/hello

The response I get is

Cannot POST /parse/1/functions/hello

Which I take to be curls perfunctory statement that it cannot find a suitable POST endpoint

What is going wrong here? I have simply changed the sample curl example from Parse.com's documentation on using cloud-code to use my parse-server installation details

like image 471
Rocket Garden Avatar asked Feb 19 '16 11:02

Rocket Garden


1 Answers

The answer is that unlike with Parses hosted solution the API version path is not something hosted with parse-server

if you host parse at e.g.: /parse as I have done above, then that is the relative URL where the functions API is available. So simply remove the /1/ from the path

The same curl command works with this URL

http://localhost:1337/parse/functions/hello

eg:

curl -X POST \   
-H "X-Parse-Application-Id: myAppId" \   
-H "X-Parse-REST-API-Key:myRESTKey" \   
-H "Content-Type: application/json" \   
-d '{}' \  
http://localhost:1337/parse/functions/hello
like image 122
Rocket Garden Avatar answered Nov 06 '22 06:11

Rocket Garden