Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Avatar Image URLs from the Azure Devops API

I'm currently working on a dashboard type application which interacts with the Azure Devops API using the C# client libraries. I connect like so:

var devOpsApi = new VssConnection(url, credentials);

And I can successfully retrieve the Team Image URLs when requesting project details:

var projectsClient = devOpsApi.GetClient<ProjectHttpClient>();
var projects = await projectsClient.GetProjects(getDefaultTeamImageUrl: true);

However, when I try to render this image in an <img> tag on my dashboard it does not display, and when inspecting the image in firefox I see the tooltip "Could not load the image". Clicking the link and Navigating directly to the image URL displays the image though.

Assumedly this is a permissions or CORS issue as when I try to view the page in incognito mode, the request gets redirected to the azure devops login page.

So to summarize: is there a way I can use these image URLs on a page that isn't azure devops?

like image 576
Adam Drewery Avatar asked Oct 24 '25 19:10

Adam Drewery


1 Answers

We can not use the image URLs on a page that isn't Azure DevOps unless you provided the correct credential to login Azure DevOps first in that page.

Then you can get the image with REST API : Avatars - Get

enter image description here

Another similar thread for your reference : VSO REST API - Getting user profile image only works with basic authentication?

like image 146
Andy Li-MSFT Avatar answered Oct 26 '25 10:10

Andy Li-MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!