FogBugz Technical Support

A forum for technical support discussion related to Fogbugz.
The current FogBugz Knowledge Base can be found at http://help.fogcreek.com/fogbugz.

Posts by Fog Creek Employees are marked:

Documentation
Release Notes
Network Status

"Not logged on" while uploading via api

I'm getting a "Not logged on" error while trying to upload an attachment via the api.

The URL I'm posting to looks like this:
https://mycompany.fogbugz.com/api.asp?cmd=edit&token=blahblah&ixBug=72&nFileCount=1

I'm pretty sure my post is formed correctly since I can point the posting code to my own webserver and get the results.  So perhaps I'm using the API incorrectly?

Any suggestions?
Tim Harrison Send private email
Tuesday, December 4, 2007
 
 
Hi Tim,

I suspect the issue is that the token isn't coming across as a multipart/form-data value.

When you're posting something, the entire POST request should be multipart/form-data ... meaning that the token, cmd, and other values that you've shown above as query string parameters should be included in your MIME-encoded form-data.

Hope that makes sense. Of course, am just speculating, as I'm no authority. However, my experience with the API (where I had similar problems) led me to this belief.

-Clay
Clay Loveless Send private email
Thursday, December 6, 2007
 
 
That sounds right, Clay.  From the API documentation at http://www.fogcreek.com/FogBugz/docs/60/topics/advanced/API.html

To upload files, use the enctype="multipart/form-data" form type and you will need an additional argument nFileCount which contains the number of files (otherwise only the first one will upload).

For example, an html page which submits to the api to create a new case would look like this:

<html>
<form method="post" action="http://localhost/fb/api.asp" enctype="multipart/form-data" >
<input type=hidden name=cmd value=new />
<input type=hidden name=token value="CCECOGMBRTPJLFUVFUAAGZCEIEYAC2" />
<input type=file name=File1 />
<input type="submit">
</form>
</html>
You can read more about this encoding type in the RFC.
Eric Nehrlich Send private email
Thursday, December 6, 2007
 
 
RULING!  Thanks Clay.  That was it.  I moved all the url params into individual parts of the multiform post.  That did it!

Someone tell ASP it should have mercy on us and parse url query parameters for posts too.  :-)

Thanks again Clay.

-Tim
Tim Harrison Send private email
Thursday, December 6, 2007
 
 
Thanks to Eric too.  Although that html form example does indicate that all params are multiform parts, it didn't get through my thick skull.  I am posting via a script, not through a web page.  A line in the docs saying something like "all url query parameters are ignored; make them multiform parts" *might* have helped (though I reserve the right to screw anything up).  :-)
Tim Harrison Send private email
Thursday, December 6, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz Bug Tracking and Evidence-Based Scheduling.