I am trying to make a script to move files from local wikipedia to commons but is getting an invalid token error. I could not search the archives and see whether this has been addressed before.
Here is what I am trying to do.
1) Get token using the following api http://commons.wikimedia.org/w/api.php?action=query&prop=info&titles...
Result: <api> <query> <pages> <page pageid="10307065" ns="14" title="Category:Commons-ml" touched=" 2011-03-14T05:01:24Z" lastrevid="49830005" counter="" length="728" starttimestamp="2011-03-25T13:16:52Z" edittoken=" 5b0b59cdc36f85c8a16b35acbb714189+\"/> </pages> </query> </api>
2) Post an image using the following api.
http://commons.wikimedia.org/w/api.php?action=upload&filename=Kerala_New...
Response
<api servedby="srv214"> <error code="badtoken" info="Invalid token"/> </api>
I am not sure whats wrong with my token here. Please advice. I dit he posting using a dot net program after including "multipart/form-data" in the header.
Thanks, Sreejith K.
On Fri, Mar 25, 2011 at 2:23 PM, Sreejith K. sreejithk2000@gmail.com wrote:
I am not sure whats wrong with my token here. Please advice. I dit he posting using a dot net program after including "multipart/form-data" in the header.
The token you are sending does not match the token you have received. Compare:
edittoken="5b0b59cdc36f85c8a16b35acbb714189+" token=5b0b59cdc36f85c8a16b35acbb714189
You are missing the +. Note that you also would need to urlencode them if you are using them in the url. (I advise though to send it as part of the multipart/form-data body, and as the very last part such that in case your connection is interrupted, the corrupted file will be rejected by MediaWiki)
Bryan
mediawiki-api@lists.wikimedia.org