I am trying to retrieve the image preview URL of documents in my OneDrive for Business. The CSOM File object has a method called GetImagePreviewUrl which takes three parameters:

  • Width
  • Height
  • ClientType

My question is about ClientType, as this is expected to be a string. I've tried to figure it out by using the following things:


But sadly, none of those worked. Does anyone know what value I have to put there? If this method turns out not to work, are there any fast alternatives?


I've found out that there is an alternative, however that doesn't suit my needs because the user logged in has to have view rights to the file, I want to get the files purely programmatically. I'll include it for anyone who has the same problem but different needs, you can find the solution here.

1 Answer 1


I've figured out how to make the alternative work, even for my situation.

Sharepoint returned a 403 error because sharepoint had no idea who I was. After some research and fiddling I found out that the request you send to the preview page contains an authentication cookie. This cookie can be generated by code using this piece of code:

// Create an authentication cookie which we can send with the request so sharepoint knows who we are.
var authCookie = credentials.GetAuthenticationCookie(new Uri(imageUrl));
client.Headers.Add(HttpRequestHeader.Cookie, authCookie);
// Download the image data to a byte array
image = client.DownloadData(imageUrl);

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.