'How do you call the Artifacts - Get File endpoint?
This is what the documentation says:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&fileId={fileId}&fileName={fileName}&api-version=6.0
But where do I get the fileId and the fileName (I assume fileName means that I also need to know the path)?
(I already know how to download the artifact as a zip but that's not what I want to do)
This is related, but I want to use documented API where I don't have to generate a full scope PAT: In Azure DevOps, is it possible to enumerate children pipeline build artifacts recursively with API?
Thanks
Solution 1:[1]
I found this post as a workaround for the issue, couldn't find any recent answers
https://developercommunity.visualstudio.com/t/download-single-file-from-artifact-via-api/1093589
Current working workaround (as of date of posting):
1. get artifact using https://docs.microsoft.com/en-us/rest/api/azure/devops/build/artifacts/get artifact?view=azure-devops-rest-5.1
2. Get Resource -> DownloadUrl string
3. Replace entire query from "?format=zip" to "?format=file&subPath={path to the item including the root}"
4. Use URL to download file
Note: To the url i had to add "%2F" before the file name that's how the actual url to the file looks like.
Update:
I asked on the developercommunity and their answer was this:
I have reviewed the ticket you mentioned, and you don’t need to get the fileID, but get the resource.data by using this API :
https://docs.microsoft.com/en-us/rest/api/azure/devops/build/artifacts/get artifact?view=azure-devops-rest-5.1
Then, use this API where resource.data is from the previous call (remove # prefix):
GET https://dev.azure.com/{organization}/{project}/_apis/resources/Containers/{resource.data}?itemPath={path to the item including the root}
A way to verify the URL you are constructing is correct, go to the Artifacts page that is linked off the Build Summary page and you will see the option to copy the download URL for an individual file there. The URL should be the same.
https://developercommunity.visualstudio.com/t/Download-single-file-from-drop-artifacts/10000465
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
