Thread:Project:Support desk/API:Upload data formatting with bash and curl

I'm having trouble importing a file to my mediawiki installation with curl and bash. I can export an XML file from one MW install, and I can login and authenticate, and I can request and receive an import token, but I can't get it to accept my imported file.

http://www.mediawiki.org/wiki/API:Import#XML_file is very vague on this point, particularly the example: "api.php ? action=import & xml=dumpcontentgoeshere". The page says that the "xml" parameter "is not a file name, but the actual contents of the file." However, there isn't any suggestion of how to pass those contents.

I've tried putting actual xml into the parameter: "xml= text " And I've tried making it a bash command: "xml=$(cat exported.xml)" But I get the result "You didn't upload a file." This could either be interpreted to mean "Your upload failed" or "You should upload a file first."

So assuming the second interpretation, I'm now trying to upload a file. I can request and receive an edit token, but I can't get the API to accept my upload.

The example on http://www.mediawiki.org/wiki/API%3aEdit_-_Uploading_files#Uploading_directly is similarly vague: "action=upload & filename=Test.txt & file=file_contents_here". The talk page says it should be passed "as part of the request in multipart/form-data format" but no matter what kind of entry I try for the "file" param, I receive the error ""

Through some experimentation I've found I can get a different error if I also include "&sessionkey=0": "".

As far as I can tell, I've met the requirements listed on http://www.mediawiki.org/wiki/Manual:Configuring_file_uploads. I'm running MediaWiki 1.17.0, PHP 5.2.6 (cgi-fcgi), and MySQL 5.1.55-rel12.6. What am I missing?