Error Code: 403 Forbidden when accessing the REST API

I am trying to access the TeamCity REST API but i keep getting a 403 Forbidden error. I have prepended the path with httpAuth and supplied my username and password but am still getting this forbidden error. If i login using the login page then navigate to these reources i am able to see tham. Is there something i am missing, something like enabling basic authentication, if so how do i do this?

Comment actions Permalink

If you are trying to access the REST Api via the browser then you can do something like this

http://yourserver:8111/httpAuth/app/rest/application.wadl - it will ask you for basic authentication details (username and password)

BUT if you are trying to do this via code you need to create a HTTPWebRequest and pass the authentication details to it

e.g. in C#

public string DoWebRequest(string address, string method, string body)        

var address = "http://yourserver:8111/httpAuth/app/rest/application.wadl";

var request = (HttpWebRequest)WebRequest.Create(address);             

request.Method = method;             

request.Credentials = new NetworkCredential("myUserName", "demopassword");             

//more code here


Comment actions Permalink

When i try to navigate to http://hostname/httpAuth/app/rest/projects using IE, it does not prompt for a username or password, it just returns Error Code: 403 Forbidden. I get the same results when i do this using the WebRequest and supplying the TeamCity credentials.

Comment actions Permalink

This method only works once the user has logged into the url in the browser, and I'm assuming it has saved the credentials. We are using teamcity v7.0.2.
Is there another way to do this that I am missing?

Comment actions Permalink

Hi Mark

http://<teamcity>/app/rest/ URL scheme is based on cookie authorization and require interactive logon.
But http://<teamcity>/httpAuth/app/rest/ interface does use explicit credentials.
What error do you get? What type of authorisation do you use - teamCity internal, NTLM or LDAP?

Comment actions Permalink

It used to work before we upgraded from 6.5 to 7.0.2
I am trying to download an artifact from teamcity.
Using C#, using a WebRequest - credentials.
It authenticates everywhere else fine, just not when I try for the artifact.

Comment actions Permalink

Mark, I cannot reproduce this issue yet.
Please check that your artifact URLs contain /httpAuth/ prefix like
http://teamcity/httpAuth/app/rest/builds/id:693/artifacts/files/Stack.dll or http://teamcity/httpAuth/repository/download/bt134/693:id/Stack.dll

If so, then please tate a dump of HTTP traffic between your tool and TeamCity server by a sniffer like Fiddler.


Comment actions Permalink

I have reason to believe it is our issue, as changing from to fixes the authentication issue.


Please sign in to leave a comment.