2

I need to update a user fields via REST SERVICE. I'm under AngularJS, so this is my function into my .service()

setMyUtx: function (params) {
            return $http({
                method : 'PUT',
                url : 'http://XXXXXXXX/rest/user/'+params.uid,
                data : {'data' : params.value},
                headers : { 'X-CSRF-Token' : $cookies['csrftoken'],'Content-Type': 'application/json;charset=utf-8'},
                cache : false
            })
        },

where params.value is :

var data = {};
      data.field_primary_aircraft = {};
      data.field_primary_aircraft.und = [{value:1}];
      ProfileService.setMyUtx({'uid' : $scope.datiUtente.uid, 'value' : data});

If I exec this function, my drupal site return no error with this output:

{"field_primary_aircraft":{"und":[{"value":0}]},"uid":"7","roles":{"2":"authenticated user"}}

But no update is done (I know it because the original value of field_primary_aircraft is 1).

Why this ? Where is my error ?

2
  • Did you walk through this with XDebug?
    – tenken
    Jul 1, 2014 at 23:00
  • 2
    You might have to include more of the user object when you post than that. When I update a node, I basically post the the same object I get back from Drupal.
    – jhr
    Jul 1, 2014 at 23:57

1 Answer 1

1

I suggest you first try to test it with a browser REST application extension. I would recommend this for Firefox: https://addons.mozilla.org/he/firefox/addon/rest-easy/

If you still doesn't get any error, check your watchdog... there is no reason this shouldn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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