c# - Using RESTapi to connect to TFS online from code -
c# - Using RESTapi to connect to TFS online from code -
i trying access projects in tfs online c# code in order info builds, tasks, projects etc. restapi, have been next documentation available online (http://www.visualstudio.com/en-us/integrate/get-started/get-started-rest-basics-vsi), however, when want json response url, get: http code 203: non-authoritative information, , hence not able json data. if seek response using postman (chrome extension) http code 200 , info need.
this code:
public static async void getbuilds() { seek { var username = "usertest"; var password = "passtest"; using (httpclient client = new httpclient()) { client.defaultrequestheaders.accept.add( new system.net.http.headers.mediatypewithqualityheadervalue("application/json")); client.defaultrequestheaders.authorization = new authenticationheadervalue("basic", convert.tobase64string( system.text.asciiencoding.ascii.getbytes( string.format("{0}:{1}", username, password)))); using (httpresponsemessage response = client.getasync( "https://myproject.visualstudio.com/defaultcollection/_apis/build/builds?api-version=1.0-preview.1").result) { response.ensuresuccessstatuscode(); string responsebody = await response.content.readasstringasync(); console.writeline(responsebody); } } } grab (exception ex) { console.writeline(ex.tostring()); } } i in response high amount of html nil close need, doing wrong?
many in advance time.
your code seems right me. have enabled alternate credentials vso account? won't work without it. here's link explaining how it.
you can check out project on codeplex: https://vsorest.codeplex.com/ shows how utilize of vso rest apis using c#
c# .net json tfs tfs2012
Comments
Post a Comment