Given the following attempt to post data to a web service that generates PDF files, PDF rocket (which is awesome by the way).
I get the err
@Mick Byrne : Thanks - your solution worked like a charme!
Here is my complete code:
public async Task DateienSendenAsync (string PfadUndDatei, string Dateiname, String VRPinGUID, String ProjektGUID, String VRPinX, String VRPinY, String VRPinZ)
{
var client = new HttpClient();
// Create the HttpContent for the form to be posted.
var requestContent = new[] {
new KeyValuePair("dateiname", Dateiname),
new KeyValuePair("bild", Convert.ToBase64String(File.ReadAllBytes(PfadUndDatei))),
new KeyValuePair("VRPinGUID", VRPinGUID),
new KeyValuePair("ProjektGUID", ProjektGUID),
new KeyValuePair("ebene", "ebene"),
new KeyValuePair("raumnummer", "raumnummer"),
new KeyValuePair("ansichtsname", "ansichtsname"),
new KeyValuePair("VRPinX", VRPinX),
new KeyValuePair("VRPinY", VRPinY),
new KeyValuePair("VRPinZ", VRPinZ),
};
String url = "http://yourhomepage/path/upload.php";
var encodedItems = requestContent.Select(i => WebUtility.UrlEncode(i.Key) + "=" + WebUtility.UrlEncode(i.Value));
var encodedContent = new StringContent(String.Join("&", encodedItems), null, "application/x-www-form-urlencoded");
// Post away!
var response = await client.PostAsync(url, encodedContent);
}