3

I'm update user profile data via services 3 but I have a problem with user picture. I send user picture to my web site via services and it works:

{"fid":"1078","uri":"http://MyDomain/rest/file/1078"}

But how can I pass this "FID" to the user update method ? Which is the correct parameter name ?

Thanks.

M.

1

The file ID is stored in the picture column of the users table

Foreign key: {file_managed}.fid of user's picture.

So your payload to the update resource would look something like

{
  "uid": "123", 
  "data": { 
    "picture": "1078",
    # rest of user data
  }
}
  • @keithm It'd make more sense if that column at least had fid in it somewhere I guess, but no, it's the picture column that stores the user picture file id – Clive Jul 23 '14 at 23:04
  • Nope. It does not works. All other data are correctly updated, but not the image profile. I have tried to add "data...." to { account : .....} but without success – ZioBudda Jul 24 '14 at 9:15
  • According to _user_resource_definition() the JSON you send should contain 'uid' and 'data' only - there's no 'account' variable involved – Clive Jul 24 '14 at 9:52
  • Clive: I have tried in all way without success. All parameters that I pass to update method works, the only with problem is "picture". I have tried to pass the same structure that I get via /user/X.json too, but always without success. – ZioBudda Jul 24 '14 at 13:22
1

The fid you pass there is just ignored. You have to write a bit of code in a module to save the fid yourself.

You can find code ready to be copy-pasted here: https://www.drupal.org/node/2471178#comment-9825329

Note: the picture_upload field is processed server-side but it won't actually work either because the file upload module looks at $_FILES and that'll be empty. The $user->picture fid will thus be set to 0 (current avatar, if any, will be removed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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