I wanted to access a TFS server, and download the dynamically produced “Scrum Burndown chart” on a regular basis, in order to re-use it in a seperate report (ie a pdf)
Yes, there is a lot of reporting going around …
How do I find the correct URL in the server to download, and how do I get around the permissions problems?
This is a question I have answered myself.
Summary of process
There is no direct URL ie I cannot ask for reportserver/myteam/burndownchart/20110815 (nice and restful) but there is a param style request for the
wrapper “report” to the image I want. Sadly there is no easy way to find it just browsing in VS2010 extension – I used Charles debugger proxy to see what VS2010 is sending.
The url you will need to directly visit the report for your team is similar to
http://tfs.example.com/reportserver?/TfsReports/ExampleCompany/ExampleProject/Sprint+Burndown+Chart&rc:toolbar=false&pReleaseWorkStreamPath=\Release01\&pSprintTeam=\Release02\Sprint01\Team01
There is some Session based obfuscation going on with the actual image URL, meaning I must call then parse the report page, to find the URL of the image, and then download it. On top of that I needed to get Python to work with Windows Authentication, and generally fiddled around a great deal
The below process is sound but the code is brittle and I just recommend it as a starting point
Identify the URL of the report
Install py-ntlm (http://code.google.com/p/python-ntlm/)
(a) You need to create a hash of user pass and requested url each time (this is invisible by browser usually)
(b) THen pass that as a urllib2 handler to urllib2
(c) process the url as usual through urllib2
SO that gets me the standard report web page, with image in it. I now need to extract that image url, for which I used a regex to get
all IMG tags and took the second one in the list. Professional and not at all brittle 🙂
We then rebuild the nltm hash (I have downloaded the HTML report page, now I want the JPG image in it),
call the URL above and write the output to local disk.
I hope that helps.
YMMV