0

I am using TFS 2020 and try accessing Rest API

http://tfs:8080/tfs/DefaultCollection/<Project>/_apis/build/builds?definitions=12345&$top=1&statusFilter=all&api-version=6.0

using basic authentication (username and password) but getting below error.

headers = {'Authorization': 'Basic navjpidW5nYUAxZQ=='}

TF400813: Resource not available for anonymous access. Client authentication required.

1
  • By default Azure DevOps disables basic auth when the server isn't configured on https for security reasons. Basic auth over http provides very little security. Commented Jan 24, 2022 at 19:02

1 Answer 1

1

I have resolved this by myself where I have used a dedicated account which has all the required permission to access the TFS API and I have used Python for this purpose.

Sample Code:

import requests
from requests_ntlm import HttpNtlmAuth
import json

username = "naveen"
password = "test"
auth = HttpNtlmAuth('domain\\username','password')

api_url = f"https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=6.0"
response = requests.get(url=api_url, auth=auth)

print(f"Output: {response.json()}")

For reference: https://github.com/requests/requests-ntlm

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.