Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting "code":105,"error":"invalid key name:" when I do a POST in my server! #1641

Closed
ckarmy opened this issue Apr 26, 2016 · 9 comments

Comments

@ckarmy
Copy link

ckarmy commented Apr 26, 2016

I really need help to implement a fix that solve my problem (similar to #68). I saw that in #105 there is a fix but in my parse-server I don't have any file called classes.js. How can I implement this?

Like @mkpazon say:

The problem seems to be due to JSON handling.
The client sends the following JSON in the body
{"where":"{"status":200,"user":{"__type":"Pointer","className":"_User","objectId":"F2ozm6Hgew"}}","count":"1","_method":"GET"}

but the parse-server returns an error.

Changing the above JSON to the following is successful
{"where": {"status":200,"user":{"__type":"Pointer","className":"_User","objectId":"F2ozm6Hgew"}},"count":"1","_method":"GET"}

@hramos
Copy link
Contributor

hramos commented Apr 26, 2016

What version of parse-server are you running?

Please refer to this issue for an example of a great bug report.

Make sure these boxes are checked before submitting another issue -- thanks for reporting issues back to Parse Server!

@ckarmy
Copy link
Author

ckarmy commented Apr 26, 2016

@hramos I'm running 2.2.7 and I have all the prerequisites. Also I search many existing issues but I can't resolve this issue.

@ckarmy
Copy link
Author

ckarmy commented Apr 26, 2016

@hramos this is an example of my error:

verbose: POST /parse/classes/watchlist { 'x-real-ip': 'xxxxxxx',
'x-forwarded-for': 'xxxxxx',
'x-nginx-proxy': 'true',
host: 'xxxxxx',
connection: 'close',
'content-length': '297',
'value-type': 'application/json',
'x-parse-application-id': 'xxxxxxxxxxxx',
'user-agent': 'Dalvik/2.1.0 (Linux; U; Android 5.1.1; SM-G925I Build/LMY47X)',
'accept-encoding': 'gzip',
'content-type': 'application/x-www-form-urlencoded' } {
"{"user":{"__type":"Pointer","className":"_User","objectId":"LEjy9IlcYB"},"movieId":"10950","MoviePoster":"https://image.tmdb.org/t/p/w600/gr0jLIUd5Os0RAFH9U5iZMpQ5cw.jpg\",\"MovieFrame\":\"https://image.tmdb.org/t/p/w600/mTN2pjZKWteb6B7WOGtrMx8FEpu.jpg\",\"MovieName\":\"Yo soy Sam","MovieRelDate":"2001"}": ""
}
verbose: error: code=105, message=invalid key name: {"user":{"__type":"Pointer","className":"_User","objectId":"LEjy9IlcYB"},"movieId":"10950","MoviePoster":"https://image.tmdb.org/t/p/w600/gr0jLIUd5Os0RAFH9U5iZMpQ5cw.jpg","MovieFrame":"https://image.tmdb.org/t/p/w600/mTN2pjZKWteb6B7WOGtrMx8FEpu.jpg","MovieName":"Yo soy Sam","MovieRelDate":"2001"}

@drew-gross
Copy link
Contributor

Which version of the android SDK are you using, and what calls are you doing to make this request?

@ckarmy
Copy link
Author

ckarmy commented Apr 26, 2016

@drew-gross I use Fuse to make apps (https://www.fusetools.com). Fuse use this SDK:

  • Android SDK platform-tools - 23.0.1
  • Android SDK build-tools - 23.0.1
  • Android 5.0.1 (API 21) - 2
  • Android 4.4.2 (API 19) - 4
  • Android Support Library - 23.2.1

And I use C# to make the HTTP request like this (this is converted to Java in the backend):

HttpMessageHandler AddToWatchL = new HttpMessageHandler();
var createRequ = AddToWatchL.CreateRequest("POST","https://xxxxxxx.com/parse/classes/watchlist");
createRequ.SetHeader("Value-type", "application/json");
createRequ.SetHeader("X-Parse-Application-Id","xxxxxxxxxxx");
var PostData = "{"user":{"__type":"Pointer","className":"_User","objectId":"LEjy9IlcYB"},"movieId":"10950","MoviePoster":"https://image.tmdb.org/t/p/w600/gr0jLIUd5Os0RAFH9U5iZMpQ5cw.jpg\",\"MovieFrame\":\"https://image.tmdb.org/t/p/w600/mTN2pjZKWteb6B7WOGtrMx8FEpu.jpg\",\"MovieName\":\"Yo soy Sam","MovieRelDate":"2001"}";
createRequ.Done += resAddWatchList;
createRequ.SetTimeout(15000);
createRequ.Error += Error;
createRequ.Timeout += TimeOutM;
createRequ.GetResponseContentString();
createRequ.SetResponseType(HttpResponseType.String);
createRequ.SendAsync(PostData);

@drew-gross
Copy link
Contributor

It looks like you are using the REST API, not the android SDK, and sending an invalid value. Did this work on api.parse.com? Can you try changing your code to submit the value that you said was working?

@hramos
Copy link
Contributor

hramos commented Apr 26, 2016

Don't escape the key names inside your where key when making a request to Parse.

This does not seem to be a Parse Server issue, as the server responds successfully when provided with a proper JSON payload (see original post).

@hramos hramos closed this as completed Apr 26, 2016
@ckarmy
Copy link
Author

ckarmy commented Apr 26, 2016

@hramos What do you mean by Don't escape the key names inside your where key when making a request to Parse.?

@drew-gross Yes, this work on api.parse.com. I have my app online with the same code and work perfect....

@ckarmy
Copy link
Author

ckarmy commented Apr 26, 2016

Sorry my mistake! I was doing the HTTP request with createRequ.SetHeader("Value-type", "application/json"); and the correct way is createRequ.SetHeader("Content-Type", "application/json");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants