A forum for technical support discussion related to Fogbugz.
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:
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?
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.
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:
<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 />
You can read more about this encoding type in the RFC.
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). :-)
This topic is archived. No further replies will be accepted.Other recent topics