Attempting to set user profile photo via API is failing

10 댓글

  • CJ Johnson

    Hi John, 
    I had this same issue a year ago. Support was never able to fix it and told me that it was not a priority and to just re-run the API commands again and again until I got the desired result. :\ 

    0
  • Eric Nelson
    Zendesk Developer Advocacy
    Hey Jon,
     
    I tested this out using the image you provided and had a similar result. When looking at logs, your server is responding back to the request with "No more references allowed". Is there a way for your image provider to add your Zendesk instance to a whitelist? This may assist with that issue. 
     
    @CJ 
     
    I'd be interested in taking a look at that ticket number if you have it. 
     
    0
  • Jon Finke

    The URL provided had a limited lifetime and use count - it had hit the max of 5. I kicked it up to 50.

    0
  • Jon Finke

    In checking the web server logs, I am not seeing any hits from Zendesk servers, so I am guessing that my API update was NOT making it in.

    I was just hoping that passing a URL to the Zendesk API would be a quick way to get photos imported to our Zendesk instances.  I am open to other alternatives - the API documentation referenced the Attachment API (IIRC), but that claimed it was limited to attachments for tickets.

     

    0
  • CJ Johnson

    Eric Nelson Sure thing - #9678190.  

    0
  • Eric Nelson
    Zendesk Developer Advocacy
    Hey Jon,

    If you want to just pass in the URL have you thought about using the remote_photo_url parameter instead? You'll need to keep the photos accessible on your server, but otherwise that'd be a simpler way of going about it.  
    0
  • Jon Finke

    I tried passing in the URL into the remote_photo_url - and that works - the photo appears on the user profile page as desired.  But I would rather not leave that URL "live" - it is intended for short term, secure access.  Checking my web server logs, it appears that the value is being cached somewhere, which is good - only one hit to my web server (this is good).  On the other hand, the reference is from a generic AWS server, so I can't "white list" the host.

    I was able to load a photo as an attachment (as suggested in the "Users" part of the API documents, but I was unable to figure out how to associate the uploaded "attachment" with the user entry.

    Just adding a "photo" element with the token resulted in a

    x-zendesk-api-warn, val={:allowed_parameters=>{:controller=>"users", :action=>"update", :unpermitted_keys=>[], :invalid_values=>["user.photo"]}}

     

    0
  • Jon Finke

    Progress of sorts - still doesn't work though.

    I am able to load the photo via the "uploads" process, and get a token and access URLs (which allowed me to confirm that Zendesk indeeds HAS the photo I uploaded).  My latest attempt to attach the photo to a user (agent) record, 

    https://rpi-registrar.zendesk.com/api/v2/users/7412860633620.json?token=vQcGDNGc9jFJM4CEkW3yOtbWv

    With the body

    {"user":{"id":7412860633620,"photo":{"uploads":["vQcGDNGc9jFJM4CEkW3yOtbWv"]}}}

    Resulted in a status code of 200 and the following:

    x-zendesk-api-warn, val={:allowed_parameters=>{:controller=>"users", :action=>"update", :unpermitted_keys=>["user.photo.uploads", "token"], :invalid_values=>[]}}

     

    The dreaded unpermitted keys error. 

    Can the uploaded/attachment followed by using the token to set the value work for a user record? Does anyone have working example?

    Do we need to have a setting changed somewhere to allow this to happen via the API?

     

    0
  • Christopher Kennedy
    Zendesk Developer Advocacy
    Hi Jon,
     
    Can you share which API endpoint you used to upload the file?
    0
  • Bryan Haeussler

    Not sure if this will be helpful for your case or not but I have been doing this successfully by only passing the string 'remote_photo_url' instead of doing anything with the photo object itself e.g.

    {
    "user": {
    "remote_photo_url": "https://example.com/example/path/image.png"
    }
    }

    The response body will not include the photo, but a subsequent GET will show the details-- I assume collecting the data from the url specified and writing the photo object, etc. is done asynchronously.

    0

댓글을 남기려면 로그인하세요.

Zendesk 제공