Skip to content

Invalid key name error. #383

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

Closed
viktor-skarlatov opened this issue Jan 31, 2016 · 5 comments
Closed

Invalid key name error. #383

viktor-skarlatov opened this issue Jan 31, 2016 · 5 comments

Comments

@viktor-skarlatov
Copy link

After calling query.find() I am getting error 105 - Invalid key name.
This happens because the ParseRESTQueryCommand changes its method from GET to POST in the last moment before being sent to the server. As a result the restWhere object on the server is a String instead of Object and the server returns error 105.

The offending code is in ParseRESTCommand :
@OverRide
protected ParseHttpRequest newRequest(
ParseHttpRequest.Method method,
String url,
ProgressCallback uploadProgressCallback) {
ParseHttpRequest request;
if (jsonParameters != null &&
method != ParseHttpRequest.Method.POST &&
method != ParseHttpRequest.Method.PUT) {
// The request URI may be too long to include parameters in the URI.
// To avoid this problem we send the parameters in a POST request json-encoded body
// and add a http method override parameter in newBody.
request = super.newRequest(ParseHttpRequest.Method.POST, url, uploadProgressCallback);
} else {
request = super.newRequest(method, url, uploadProgressCallback);
}
ParseHttpRequest.Builder requestBuilder = new ParseHttpRequest.Builder(request);
addAdditionalHeaders(requestBuilder);
return requestBuilder.build();
}

After I comment out the change to POST everything works fine, however I can't figure out if the request being too long will hurt me at some point.

I am using your parse-server node module and your Android SDK as is, no changes on my part.

@smanikandan14
Copy link

I am too facing this problem. When i intercepted the network calls, i found the request body was carrying information as _method:GET, but the HTTP request was a POST.

HTTP POST Request Body - JSON.

{
    "include": "city",
    "where": "{\"phonenumber\":\"11111111\"}",
    "limit": "1",
    "_method": "GET"
}

HTTP Response Error code: 400 Bad Request

{
    "code": 105,
    "error": "invalid key name: 0"
}

Not sure where the fix should be. Server side code or Android client side SDK.

@yeahio-coltd
Copy link

I am also getting this error on my Android app. Looking for fixing 👍

@smanikandan14
Copy link

In case anyone interested this PR changes solved this issue. parse-community/parse-server#105. I had this change on my parse-server - Classes.js. And the issue is gone.

@grantland
Copy link
Contributor

Thanks for stepping in @smanikandan14! I'll be closing this as resolved.

FYI queries are sometimes sent as POST instead of GET as a workaround for URI length limits.

@ckarmy
Copy link

ckarmy commented Apr 25, 2016

@grantland @smanikandan14 How can implement this? In my parse-server I don't have a file called classes.js! I really need help to solve this problem! My Parse version is 2.2.7.

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

5 participants