15

8

I have 500+ tasks in Excel with these columns:

  • Title
  • Milestone
  • Assigned To
  • Area
  • Priority
  • Tags

What's the simplest way to get these into FB using the API? I'm in a .NET environment, and I suppose I could read in the Excel file, build an XML payload for each row, and then POST it to the API. There's got to be an easier way, though. Any thoughts?

flag

8 Answers

20

I finally got this to work - hopefully this will be helpful to someone trying to do something similar. I've posted the spreadsheet and supporting files at www.caudillweb.com/downloads/fb.zip.

  1. I got the API token by logging in as described on this page by @Michael Pryor. A single token lasted long enough for me to get this done. (ed: API tokens last until you click log off in the web interface.) I added this as a named cell in Excel.
  2. I added a UrlEncode function to my Excel workbook
  3. I added a "Command" column to the worksheet containing the tasks, with this formula:

    ="https://caudillweb.fogbugz.com/api.asp?token=" & Token & "&cmd=new&sProject=ICM&sFixFor=" & D6 & "&sArea=" & urlencode(C6) & "&hrsCurrEst=" & F6 & "&sTags=" & SUBSTITUTE(G6," ",",") & "&ixPriority=" & E6 & "&sTitle=" & urlencode(H6) & "&sEvent=" & urlencode(I6) & "&sPersonAssignedTo=" & urlencode(B6)

  4. I used wget.exe to fire off the URLs - you can download this as a self-contained executable here . You'll need to put this in a system path.

  5. I copied and pasted the contents of the Command column into a text file, fb.txt .
  6. I then made a batch file, fb.bat, containing the following command:

    wget --spider --no-check-certificate -i "x:\users\herb caudill\desktop\fb.txt"

    This tells wget to hit all the URLs listed in the text file. The --spider switch tells it to ignore the results rather than saving them as a file; the --no-check-certificate switch tells it to ignore SSL certificate issues.

link|flag
That's just awesome. – Rich Armstrong Nov 6 2009 at 23:16
Just used this again. I wish I could vote it up again! – Rich Armstrong Jul 28 2010 at 22:30
Used this method to import 120+ item backlog I had in Excel. Very nice! – Paul Tiseo Apr 5 2011 at 15:09
This does not work for me. I am on Win 7 x64, and although I get a 200 response when I use --spider, FogBugz does nothing with the API command that I can see. – Chris M Jan 17 2012 at 15:21
BTW, referenced fb.zip is broken - the included UrlEncode function is broken, you should refresh it from the original source (referenced question). For example, it breaks for me when I add "[" or "]" character to be URL encoded. – Neeme Praks Aug 8 at 13:31
7

All: I found that the answer above worked perfectly, but wasn't facile enough for my client, so I wrote a VB application that does the trick. Also, I wrote it so that it pulls straight from the Excel spreadsheet, so no export is needed.

http://devshed.us/Products/FogBugzCaseImporter.aspx

(please up vote this answer if you found it useful)

link|flag
Thanks Steve, this was super simple to use. Definitely the easiest way to bulk load cases from Excel to Fogbugz. Cher! – MrGlover Nov 16 2010 at 20:10
I found this tool to fail to start.. Win7, WinServer2003, WinXPsp3...all three fail with various errors. Too bad too...this looked like an excellent tool. – Brian Ackermann Jan 12 2012 at 20:22
There are a couple of error pop ups, but it didn't matter. Worked perfectly on Windows XP. You saved me a lot of time! Thanks again. – bluntcoder Oct 2 at 19:59
@steve I just emailed you as your site devshed.us seems to be down – adambox Feb 12 at 19:08
1

Step 1. Execute this in the browser: http://yourfogbugz/api.asp?cmd=logon&email=blah&password=foo Step 2. You should have an API token now. Take what PJM said and make some Excel macro that builds a url of the form http://yourfogbugz/api.asp?token=blah&cmd=newcase&sTitle=thetitlevaluefromyoursheet&sPersonAssignedTo=thepersonfromyoursheet

You'll need to set up the areas, persons, milestones, etc beforehand.

link|flag
OK - that's straightforward enough (doesn't need to be an macro, I can just build the URLs by building the string in a new column). This might be a dumb question, though - what's the easiest way to call hundreds of different URLs? Just put them in a batch file and run that? – Herb Caudill Oct 29 2009 at 22:23
Use the XMLHTTP object: scriptorium.serve-it.nl/view.php?sid=40 – Michael Pryor Oct 30 2009 at 2:26
0

I had some success using Excel VBA macros to pull Case lists from the API and map the XML responses to tables in a spreadsheet. You could do the same, with a macro that walks through your table of cases.

I took that approach because I had started with some Excel tables like you... but quickly learned to hate Excel VBA. with hindsight, I say "stick with the technology you are familiar with". I'm not a .NET developer, but I expect that for someone experienced in it the approach you suggest will be the easiest.

link|flag
I don't think you need macros to get a case list in Excel: blog.fogcreek.com/… – Michel de Ruiter Jan 18 2012 at 8:42
yup, that blog describes what you would do once, but after two or three times you'll be asking "how can I automate this? – PJM Feb 2 2012 at 16:04
0

yup, that would work... export the column of URLs into a newline separated text file and pipe that to a command line http Get utility.

(or, set up an XML map in Excel and write a macro to step through the table. I know you're not going to do this, but for the curious, the method to use is WorkBook.XmlMaps("map-name").Import URL:="see above answer" )

link|flag
0

Thank you for this info, it is exactly what I needed. There is one issue I haven't been able to work out yet and wonder if you have any ideas. When I use the API to enter a new bug, I want to send in a new line character in the sEvent arg. I've tried all the new line characters I can think of but none work. I entered a bug directly into FogBugz via the UI and then went into the database to see how it stored the newline characters inside the database and all I see is a strange square character that I can't copy and paste.

Any ideas?

Thanks in advance, great article! Bruno

link|flag
1 
@Bruno, you would have to URL-encode that. E.g. %0A%0D. – Avi D Dec 13 2010 at 16:21
0

I just tried using wget, and I don't get any new bugs created.

Fore each URL I get the message:

"HTTP request sent, awaiting response... 200 OK"

but when I check the database no bugs were created. When I test the URLs directly in the browser, they work no problem. I'm not sure what I am missing.

edit

If I remove the --spider argument, it adds the bugs, but ends up ignoring the ixBug param, instead starting with the last bug # specified by that param and increasing by one for each bug in the list.

link|flag
You might be experiencing a problem that I noticed a while back myself when importing bugs. Fogbugz -will- let you set the bug# but only if it's a higher number than the largest bug# already added (i.e. if bugs 1000, 2000, and 3000 exist and you attempt to make bug# 2500 it will revert to 3001, but if you attempt to make bug#4000 it should work). Unless of course you're importing bugs numerically, then I am of no help at all – JessT Jan 16 2012 at 17:57
Yeah I am accounting for that, but of course per my results without the --spider argument that is what is happening. My biggest problem is that nothing is happening with the --spider arg, even though it is supposed to work. – Chris M Jan 16 2012 at 18:21
0

Instead of using wget, I tried using curl for Windows (x64 even) instead, and I managed to finally get it to work.

I created a text file in the format of:

url = apiUrl1<br />
url = apiUrl2<br />
url = apiUrl3<br />
...

and so on, using the method Herb did for concatenating the URLs (and also adding the "url = " at the beginning of each URL) in Excel. I then copied and pasted the column of URLs into a text file, fb.txt.

Then from command line, I ran curl:

curl -K fb.txt

and it worked perfectly.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.