• Register
0 votes
494 views

Problem :

We upgraded to TFS 2017 and our API calls stopped working and we started receiving following error:
"TF400813: Resource not available for anonymous access. Client authentication required.". Anything in [] brackets was replaced.

I amt don’t know why the code block is having issues.

using (var myclient = new HttpClient(new HttpClientHandler()))
{
myclient.Timeout = TimeSpan.FromMinutes(3);
myclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(Encoding.ASCII.GetBytes("[domain]\\[username]:[password]")));
myclient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage myresponse = myclient.GetAsync($"https://[server]:8080/tfs/[node]/[node]/_apis/build/builds?api-version=2.0&definitions={buildDefinitionNumber}&resultFilter={resultFilter}&$top={maxBuildCount}").Result;
var myresult = myresponse.Content.ReadAsStringAsync().Result;
return (JArray)JObject.Parse(myresult)["value"];
}
6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

As a solution on yhe issue, I just created a personal access token (PAT) and I was able to get authenticated using that PAT.

This is not the ideal way as I am putting my personal access token in the code to get this working. I was using the service account so now I am trying to understand that how can I create a PAT for the service account and/or I am still trying to figure out a way to make it work like it once did because I can not login to the TFS dashboard with the service account.

Please refer the following Updated Code:

string mycredentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", "<PAT>")));
myclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", mycredentials);

 

Further Readings :

I refered below articles:

https://www.visualstudio.com/en-us/docs/integrate/get-started/authentication/pats

https://www.visualstudio.com/en-us/docs/integrate/get-started/rest/samples

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 329 views
329 views
Problem : I have created one of the WCF service and deployed it on the Server. When I browse this service it gives me positive response with the wsdl URL. Now I am trying to test my service through the WCF Test client. It shows me ... factory) The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'.
asked Jan 23, 2020 jwilliam 3.9k points
0 votes
1 answer 245 views
245 views
Problem : I want to send mails using my web application. But my below code is showing me the below error: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not authenticated to send ... false; mysmtp.Timeout = 600000; } // Passing values to smtp object mysmtp.Send(myfromAddress, mytoAddress, mysubject, mybody); } } }
asked Dec 9, 2019 alecxe 7.5k points
0 votes
1 answer 140 views
140 views
Problem : I am very new to node.js and MySQL and I have just started setting up and also trying out some basic code. But, I am unable to make even the simple connection to a server for some reason. I have also installed a newest MySQL ... ; console.log("Connected!"); }); My Error: &ldquo;Client does not support authentication protocol requested by server consider upgrading mysql client&rdquo;
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 153 views
153 views
Problem: I have very recently integrated my Tomcat 7 in Eclipse. If I start Tomcat 7 using Eclipse then it shows that my Tomcat is up and running but if I go to http://localhost:8080 in the browser then it gives me following error: HTTP Status 404 - / type Status report ... is already in use by some other service but that did not work either for me. How can I fix above error related to Tomcat 7?
asked Aug 2, 2020 Raphael Pacheco 4.9k points
2 votes
1 answer 154 views
154 views
Problem : I am currently learning to use the windbg to debug the crash dump. I am facing following error. What is the meaning of &ldquo;first/second chance not available&rdquo; ? This dump file has an exception of interest stored in it. The stored exception information ... via .ecxr. (e38.2270): Access violation - code c0000005 (first/second chance not available) How can I fix above error?
asked Mar 25, 2020 morrisBson 3.2k points
0 votes
1 answer 37 views
0 votes
1 answer 2.3K views
2.3K views
Problem : I got stuck on below error I am trying to configure my SMTP mail on laravel &ldquo;Expected response code 250 but got code "530", with message "530 5.7.1 authentication required "&rdquo; Below is the configuration on .env MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io ... I have tried to authenticate my SMTP on the env but I keep facing the above error so for now I am stuck on that error.
asked Feb 4, 2020 jwilliam 3.9k points
0 votes
1 answer 115 views
115 views
Problem : I am using my home network to share my files between devices in my household with no problem, but very recently I had to re-install the Windows 10, after that, no devices were shown under the Network in File Explorer. I can surely ping my devices ... Home network System error 6118 has occurred. The list of servers for this workgroup is not currently available. What seems to be a problem?
asked Feb 3, 2020 jwilliam 3.9k points
1 vote
1 answer 22 views
22 views
Problem : I have created the web application and trying to host my site using the wordpress. But when I try to search the name of my site in goole it is showing me below error : A description for this result is not available because of this site's robots.txt the ... I know nothing about that error if someone could help me here Why is this happening to my site. Is there any problem in my site?
asked Dec 27, 2019 alecxe 7.5k points