In our team, we follow the docs-as-code approach, and have some plantUML files in our git repository, which is hosted by an azure devops server (i.e., on premise). Now we want to serve the UML diagrams as hyperlinks on another website. The idea is that if the users browse with chrome, and have the plantUML viewer extension installed, they can view the diagram in the browser by clicking on the link.
We use the REST API for interacting with the git repository as follows:
Here of course tfs.contoso.com is replaced with our azure devops server host, foo with the id or name of the team project and bar with the id or name of the repository.
Unfortunately, Chrome downloads the file instead of displaying it in the browser. My guess is that the extension, although installed, does not get a chance to render the content. How can I achieve that the content gets displayed instead of downloaded?
Use Azure Devops Git Api to view UML file in browser
I will get the same result "Chrome downloads the file instead of displaying it in the browser" if I use the same REST API Items - Get as you.
To resolve this issue, please try to use the REST API Source Providers - Get File Contents:
GET https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/{providerName}/filecontents?&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=5.0-preview.1
Note:
serviceEndpointId
.providerName
. In short, you could use TfsGit
. You could got this value from the list of source providers.You could refer this answer for some more details.
My test result: