I dont want to download the json file but I want the json to show it
in the extension.
As I know we don't have such API to access the content of one file within artifact directly.
While the Client Libraries
like Web Extensions SDK(VSS.SDk)
and .Net Client Library support most Rest API , none of them supports accessing metadata of file directly. For now only the metadata of file in git repo can be accessed via API directly. Let's check the difference:
1.The API to get file in artifact:
Rest API:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=5.1
(The one you used)
C# client:
BuildHttpClientBase.GetArtifactContentZipAsync Method (Use BuildHttpClient
class)
JS Web(VSS.SDK):
getArtifactContentZip()
2.The API to get file metadata in git repo:
Rest API:
GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/items?path={path}&api-version=5.1
Supports getting metadata if includeContentMetadata
is set to True.
C# client:
GitHttpClientBase.GetItemAsync or GitHttpClientBase.GetItemContentAsync (They both supports getting Item Metadata and/or Content for a single item, haven't tested it to check which is better)
JS Web(VSS.SDK):
getItem() and getItemContent()
. (Get Item Metadata and/or Content for a single item.)
To sum up: What you actually want is to access the metadata so that you can access the content within file directly. But for now the Artifact-related api is not supported to do such job. So I'm afraid the answer is NO, what you want is not supported in current version of API.
As an alternative workaround, I suggest you can submit a feature request here in our User Voice forum to share your feedback. The product team would consider about your idea if it gets enough votes.