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

save Record got error #138

Open
yuchangfu opened this issue Jun 16, 2017 · 0 comments
Open

save Record got error #138

yuchangfu opened this issue Jun 16, 2017 · 0 comments
Labels

Comments

@yuchangfu
Copy link

yuchangfu commented Jun 16, 2017

I use this code to save a Record

HashMap<String ,Object> commentData = new HashMap<>();
                commentData.put("title","haha comment");
                commentData.put("data","world is bad");
                Record aComment = new Record("Comment",commentData);
                skygear.getPublicDatabase().save(aComment, new RecordSaveResponseHandler() {
                    @Override
                    public void onSaveSuccess(Record[] records) {
                        Log.i("MyApplication", "Record saved");
                    }

                    @Override
                    public void onPartiallySaveSuccess(Map<String, Record> successRecords, Map<String, Error> errors) {
                        Log.i("MyApplication", "Some records are failed to save");
                    }
                    @Override
                    public void onSaveFail(Error error) {
                        Log.w("MyApplication", "Failed to save: " + error.getMessage(), error);
                    }
                });

The request body like this:
{
"database_id": "_public",
"api_key": "123456789",
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyNjc1N2UyZC01Yzg3LTQ4YTQtYjY2Ni05MmY1YWRlMjQ1MjAiLCJpYXQiOjE0OTc1ODA5MzMsImlzcyI6ImVhc3lib29rIiwic3ViIjoiMWNjOGViYWQtZGYwMy00MjAxLThkMWQtMmQ1YmYzOWYwNDQ4In0.BuD5x13I5TLQcdUz5CRAzscaMyWgnx5BnifFNcrq0Yc",
"action": "record:save",
"records": [{
"data": "world is bad",
"title": "haha comment",
"_id": "Comment/84004521-76ca-402e-a050-1ffd13876f32",
"_created_at": "2017-06-16T02:42:31.898Z",
"_updated_at": "2017-06-16T02:42:31.898Z",
"_access": [{
"level": "read",
"public": true
}]
}]
}

and get this error
{
"error": {
"name": "BadRequest",
"code": 107,
"message": "fails to decode the request payload"
}
}

What cause this problem and how to fix it

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

No branches or pull requests

2 participants