4

Right, so I'm simply trying to update my object via the REST API. My request succeeds, I get a 200 response back containing the latest updated timestamp, but the object's column value has not changed.

My Movies class has a title and a genre column, the rights on the class are set to public read write on all rows.

Here is some code

var data = {title:'The Revenant'};

qwest.put('https://api.parse.com/1/classes/Movies/myObjectId', JSON.stringify(data))
    .then(function(xhr, response) {
        console.log(response);
    })
    .catch(function(xhr, response, e) {
        console.log(e);
    });

The response I get back?

{"updatedAt":"2016-01-24T07:59:54.977Z"}

So the request succeeded but if I GET the object again or check in the Parse admin page, the object has not changed. What gives?

EDIT

FYI, if I use the Javascript SDK, I can update the model.

var Movies = Parse.Object.extend("Movies");
var query = new Parse.Query(Movies);

query.get(myObjectId, {
    success: function (movie) {
        movie.set("title", data.title);
        movie.save();
    },
    error: function (object, error) {
        console.log(error);
    }
});

This updates the model. For my particular use case though, I would really prefer to use the REST API rather than the SDK, but I guess this means it is not a permissions issue or an id mismatch etc.,

2
  • var data = {"title":"The Revenant"}; try it out.. may work better Commented Jan 24, 2016 at 15:21
  • This gives a 400 response due to invalid JSON. Commented Jan 25, 2016 at 23:08

3 Answers 3

3

code snippet

qwest.put('https://api.parse.com/1/classes/Movies/Dh7zjiP9KW', data,    {dataType:"json",headers:{'x-parse-application-id':'XXX','X-Parse-REST-    API-Key':'XXX'}})
            .then(function(xhr, response) {
                console.log(response);
            })
            .catch(function(xhr, response, e) {
                console.log(e);
            });
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Setting the data type explicitly was the necessary step.
0

The response you're getting indicates that the object was updated successfully. Double check that you're looking at the correct object, and that the "updatedAt" field matches the response you saw earlier.

What happens if you fetch the object right away, using the same "qwest" client and https://api.parse.com/1/classes/Movies/myObjectId resource URL (with the correct object id)?

2 Comments

Yep, object is correct. If I perform a get request inside of the then promise the correct object comes back. Its timestamp has been updated but its title remains the same.
Can you elaborate on the client you're using? Which headers are you setting when making this request?
0

Try removing JSON.stringify(data) and just pass data,

2 Comments

Below code works for me, I set the datatype to json.
Hmm I'll try explicitly setting the data type and report back

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.