-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't add user photo #194
Comments
I'd like to second this - I'm trying to sync user details from Active Directory to Zendesk and this is the last bit I can't finish. |
Well, until we can get a response, I wrote the following bit of code today that seems to work. Drop me a line if you have any questions. Create a class with just this in it and then call the method as a static instance:
You can call it like this to put the photo in. The user is the User object you got back from the API.
Or like this to blank out the photo:
|
Hey, that’s great! I’ve done a brief read through and it’s just what I need, will apply this ASAP. Thanks so much for your help! |
I can't seem to add a user photo. I get the user, and then I run this code:
// Find the file we're looking for
string targetFile = @"EmpPhoto.jpg";
ZenFile file = new ZenFile();
file.ContentType = "image/jpeg";
file.FileData = File.ReadAllBytes(targetFile);
file.FileName = "EmpPhoto.jpg";
var uploadedFile = api.Attachments.UploadAttachment(file);
string url = uploadedFile.Attachments[0].ContentUrl;
Photo ph = new Photo();
ph.Id = uploadedFile.Attachments[0].Id;
ph.ContentType = uploadedFile.Attachments[0].ContentType;
ph.ContentUrl = url;
ph.Size = (int)new FileInfo(targetFile).Length;
ph.Name = "EmpPhoto.jpg";
// Create a thumbnail
Thumbnail nail = new Thumbnail();
nail.ContentType = ph.ContentType;
nail.ContentUrl = ph.ContentUrl;
nail.Size = ph.Size;
nail.Id = ph.Id;
user.RemotePhotoUrl = ph.ContentUrl;
user.Photo = ph;
IndividualUserResponse userResponse = api.Users.UpdateUser(user);
The user object has the photo on my side, but the response user doesn't have a photo set. What am I doing wrong? BTW - the photo is up on the site - I can browse to the URL.
Thanks,
Mark
The text was updated successfully, but these errors were encountered: