views:

150

answers:

3

Hello. 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!

A: 

Why do you append "%2B%25C" to your querystring? It translates to " \" (space - antislash) which is strange since it will be part of the received token.

Try to issue the POST request without these noise characters.

Yann Schwartz
thanks for your quick answer."+\" have to be part of the token .... (MediaWiki/api.php)I tried it without but the problem isnt solved :/
Alex
A: 

Perhaps someone can say, if the code looks correct or not?!

Is there any difference between UploadStringAsync and HttpWebRequest?

Alex
+1  A: 

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

Alex