Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to do an update on an object from my db (parse.com), So, I saw the docs and look likes so easy but I think I forget some dummy thing... but I'm not able to find it... Could you help me, please?

I'm doing this request:

$.http({
     method: 'PUT',
     url: myURL + 'objectID of object to update',
     headers: {'X-Parse-Application-Id': appId, 'X-Parse-REST-API-Key': restId,
               'Content-Type': 'application/json'},
     data: {'name' : 'new name'}

  }).success(function(data){
     console.log(data)

  }).error(function(data){
     console.log(data)

  });

here, the docs says like you have to do this kind of request: https://parse.com/docs/rest/guide#objects-updating-objects

Thanks a lot, if you need some information more, let me know.

EDIT: Sorry, I'm getting an error 400 (Bad Request)

share|improve this question
    
Does myURL have a trailing '/'? If not, that would explain a 400. –  danh May 22 at 17:06
    
@danh Yes, the url is correct because I'm using this url for GET request. I erase data and change the method to GET and works fine... –  Alejandro Lora May 22 at 22:31
    
Oh. Good hint. Does a non-user have sufficient permission to write the class? –  danh May 22 at 23:39
    
?? I don't understand your last question, I'm calling trough API REST and call with angular service (like AJAX), So, I think everybody can change data with keys. @danh –  Alejandro Lora May 22 at 23:45

1 Answer 1

up vote 0 down vote accepted

I found the issue. Server of parse.com, must get a json object, for this reason I wrote content type json-application but I forgot write this:

var obj = {'name': 'new name'};

. . .

//inside of http service
data: JSON.stringify(object);

I will never forget that!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.