parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

CURL request not working

Open gateway opened this issue 10 years ago • 8 comments

I have set up the parse server on Heroku connected to MongoLab and I keep getting this even though the api key is correct.

gatewaysmacpro:parse-server-example gateway$ curl -X POST \

-H "X-Parse-Application-Id: XXXXXXXXXXXXXXXXXXXXXXX"
-H "Content-Type: application/json"
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}'
https://xxxxxx.herokuapp.com/parse/classes/GameScore {"error":"unauthorized"} gatewaysmacpro:parse-server-example gateway

any ideas what could be causing this?

gateway avatar Feb 01 '16 03:02 gateway

check the route of api

mghohoo avatar Feb 01 '16 04:02 mghohoo

Are you sure the appId is the same in your ParseServer initialization?

gfosco avatar Feb 01 '16 05:02 gfosco

+1 mine dev environment in localhost instead of heroku, but same result

atom2ueki avatar Feb 01 '16 09:02 atom2ueki

You also need to include the REST API Key or Parse-Master-Key in your POST request, I can see you've only included the Application Id, try adding one of the two to your request as below

-H "X-Parse-REST-API-Key: XXXXX" \

Or

-H "X-Parse-Master-Key: YOUR_APP_MASTER_KEY" \

christianmarth avatar Feb 01 '16 09:02 christianmarth

@gateway in node_modules/parse/lib/node/CoreManager.js make sure SERVER_URL pointing to your server.

ravikanchikare avatar Feb 03 '16 13:02 ravikanchikare

Closing as this hasn't been updated in a week and a solution seems to have been provided.

drew-gross avatar Feb 11 '16 02:02 drew-gross

Just as a FYI, I ran into this problem when setting an App ID & Master Key, looking thru the code remember to create environment variables like:

APP_ID = your-app-secret
MASTER_KEY = your-master-key-secret
SERVER_URL = your-heroku-url/parse

curl -X POST \
  -H "X-Parse-Application-Id: your-app-secret" \
  -H "X-Parse-Master-Key: your-master-key-secret" \
  -H "X-Parse-Url: https://your-heroku-url/parse" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  https://your-heroku-url/parse/classes/GameScore

Once all setup and sent, curl should return:

{"objectId":"WBgSBMGl1Y","createdAt":"2016-05-27T15:32:16.410Z"}%

johnantoni avatar May 27 '16 15:05 johnantoni

My curl post request works ok and returns the object id of newly created object, but curl GET requests return {"error":"unauthorized"} wtf

in CoreManager.js i changed the SERVER_URL to my server, didnt help

UPD:

i had a typo in my request, now everything is ok

lxknvlk avatar Oct 14 '16 11:10 lxknvlk