8

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

3
  • The Cannot POST /parse/1/functions/hello looks like a response from the server, not something curl said. Possibly adding -v to the command line helps you with some more clues. (and the "-X POST" part should be removed) Commented Feb 19, 2016 at 11:52
  • Yes, correct the message is a response from the server that an end point cannot be found. The answer works as described Commented Mar 10, 2016 at 11:52
  • how do I make the parse client js sdk make the calls without the /1? Commented Jan 3, 2017 at 11:36

2 Answers 2

14

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
Sign up to request clarification or add additional context in comments.

Comments

0

I applied the "hello post" logic below to run a function that is defined in Parse Open Source cloud code in main.js hosted on heroku. I am trying to replace a former job that ran on parse.com. Started with Curl to try and be able to run function at will.

error: Cannot GET /parse/functions/sendOutboundProgressReport STATE: PERFORM => DONE handle 0x6000578c0; line 1981 (connection #2) multi_done Curl_http_done: called premature ==0 Connection #2 to host test-fake-app.herokuapp.com left intact Expire cleared


curl -v POST \

-H 'X-Parse-Application-Id: sadf435hsdgfatea' \ -H 'X-Parse-Master-Key: asdfsaasdfae4235dsgd' \ -H 'REST_KEY': asdfasq435636 \ -H "Content-Type: application/json" \ -H "X-Parse-Url: http://test-fake-app.herokuapp.com/parse" \

-d @send-template.json \

http://test-fake-app.herokuapp.com/parse/functions/sendOutboundProgressReport

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.