C# – Delete (MediaWiki) Page with C# (HTTP POST)

apic++httpmediawikipost

I try to delete a page like this:

WebClient wClient = new WebClient();
wClient.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);

string str_post = "action=delete" + "&title=Vorlage:" + str_zuloeschendeVorlage + "&token=" + str_token + "%2B%5C";
wClient.UploadStringAsync(new Uri(@"http://localhost/mediawiki/api.php"), "POST", str_post);

The Token is not the problem (i got a correct one). And i'm logged in as admin. The callback client_UploadStringCompleted is called correct (with a correct connection). No error code returns (from api). The result is just the code from the api.php (with no error code). But the site is still there. I think the uri or the str_post is wrong.

Please help!

Best Solution

i found the problem...

the headers-information was missing:

WebClient wClient = new WebClient();
wClient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
wClient.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);

the rest of the code is correct