i try to execute a Post Request with Postdata, wich are partial urlencoded. i have the following PostData to send:
p1=v1
p2=v2
p3=up1=uv1&up2=uv2
in order to achieve this, i format the value of p3
p3=up1%3duv1%26up2%3duv2
Then i write everything in one String value:
p1=v1&p2=v2&p3=up1%3duv1%26up2%3duv2
Now i have a Post Request:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "POST";
byte[] data = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.Headers["ContentLength"] = data.Length.ToString();
using (Stream stream = await request.GetRequestStreamAsync())
{
stream.Write(data, 0, data.Length);
}
WebResponse response = await request.GetResponseAsync();
Stream streamResponse = response.GetResponseStream();
But the target url now receives
p1=v1
p2=v2
P3=up1=uv1_up2=uv2
a _ instaed of & additionally and nevertheless i'm using UTF8 encoding Charakters like äüö are broken.
I Tryed several encodings (ASCII, iso-8859-1) but always the same.
The final question is, how to post a urlencoded String ?