I am looking for a sample REST Client that can update user thumbnailphoto using Azure AD graph API? REST Client to Get is there and it works https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#GetUserThumbnailPhoto
I tried this sample Java Rest Client but Received 405 - Method Not Allowed:
public void updateUserPhotoGraph(ModelMap model) throws IOException {
//https://graph.windows.net/{tenant}/users/{user}/thumbnailPhoto?api-version=1.6
UriComponents uriComponents = getPhotoUri();
String bearerToken = getBearerToken();
try {
HttpClient httpclient = HttpClients.createDefault();
byte[] bytesEncoded = Base64.encode(extractBytes());
URIBuilder builder = new URIBuilder(uriComponents.toString());
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + bearerToken);
request.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_OCTET_STREAM);
request.setEntity(new ByteArrayEntity(bytesEncoded));
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
System.out.println(EntityUtils.toString(entity));
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
** Changed the above to sent PATCH request as well, but got the same error.
Anyone used this API to update thumnailphoto?
Can we use [https://graph.windows.net/{tenant}/users/{user}/thumbnailPhoto?api-version=1.6] to Update/Set Thumbnail photo?
What would be the the right API for that?