Can I download a file from Azure DevOps using the Curl command

Greg Smith 1 Reputation point
2024-10-11T21:54:56.43+00:00

I would like to download a file from Azure DevOps repo using the "curl" command. Here is the command I use:

The syntax I use is:

curl https://hc-it-ops.visualstudio.com/_git/WebSphere/Repo/Files/windows_test.yml

... and I get the error message:

     </div>

      <div class="error-info">

        <div class="title">404 - Page not found</div>

        <div class="details">**Looks like this page doesn't exist or can't be found. Make sure the URL is correct**.</div>

        <div class="reference-data">

          <div>10/11/2024 9:43:54 PM (UTC)</div>

          <div>70d93fcb-4bf1-4cec-a1be-d50ac3fb0702</div>

        </div>

        <div class="action-container">

          <a class="action" href="https://hc-it-ops.visualstudio.com/">

            <span>Go back home</span>

          </a>

        </div>

I can't assemble to correct path to the file I want.

FYI - I want to use the curl command because we use Windows and Linux. The command is accessible on both operating systems.

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,306 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,934 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Sina Salam 12,166 Reputation points
    2024-10-11T22:27:41.05+00:00

    Hello Greg Smith,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you would like to download a file from Azure DevOps using the Curl command.

    The URL and token need to be accurately set, and the curl command will look like this:

    curl -u myPAT: \
    "https://dev.azure.com/hc-it-ops/MyProject/_apis/git/repositories/WebSphere/items?path=/Repo/Files/windows_test.yml&api-version=7.1-preview" \
    --output windows_test.yml
    

    What you should note in above command is that the Correct API URL where /hc-it-ops/MyProject/

    organization or your Azure DevOps organization name, and the name of your project. Then, myPAT is a need to authenticate using a personal access token (PAT). You'll pass this token in the Authorization header. You can create a PAT in Azure DevOps under "User settings > Personal access tokens."

    Then, make sure you have the correct permissions to access the file in the repository, and the file path is exactly as it appears in your repo (case-sensitive).

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    0 comments No comments

  2. Vinod Kumar Reddy Chilupuri 735 Reputation points Microsoft Vendor
    2024-10-14T05:38:37.1533333+00:00

    Hi Greg Smith,
    Welcome to Microsoft Q&A! 

    Your issue is related to Azure DevOps, please report it in dedicated Azure DevOps forum.

    Thanks for your understanding. 

    Sincerely,
    Vinod


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Sina Salam 12,166 Reputation points
    2024-10-15T20:28:20.43+00:00

    Hi Greg Smith,

    Thank you for your feedback.

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Accepted answers show up at the top, resulting in improved discoverability for others.

    Issue: Can I download a file from Azure DevOps using the Curl command

    Solution: @Greg Smith

    Used the following, including many iterations:

    curl -u <mypat>: -O https://hc-it-ops.visualstudio.com/WebSphere/_git/repositories/WebSphere?path=/Files/Access_Windows_Network_Drive.yml

    @Vinod was able to direct to the correct site - https://developercommunity.visualstudio.com/AzureDevOps/report

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.