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=Category:Commons-ml&intoken=edit&page=edittoken&format=xml

Result:
<api>
<query>
<pages>
<page pageid="10307065ns="14title="Category:Commons-mltouched="2011-03-14T05:01:24Zlastrevid="49830005counter="length="728starttimestamp="2011-03-25T13:16:52Zedittoken="5b0b59cdc36f85c8a16b35acbb714189+\"/>
</pages>
</query>
</api>

2) Post an image using the following api.


Response

<api servedby="srv214">
<error code="badtokeninfo="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.