Reputation: 1432
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.
Upvotes: 0
Views: 1077
Reputation: 1432
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
Upvotes: 1