1
byte[] requestBytes = System.Text.Encoding.ASCII.GetBytes(message);
request.Method = "POST";
request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = requestBytes.Length;
request.Headers.Add(string.format("infoAsString, {0}", infoAsString))

using (Stream requestStream = request.GetRequestStream())
{      
    requestStream.Write(requestBytes, 0, requestBytes.Length);
    requestStream.Close();
}

iv tried this and in debug when code reaches the request.Headers it throws : Specified value does not have a ':' separator. Parameter name: header

Also tried:

request.Headers.Add("infoAsString, {0}", infoAsString)

&

request.Headers.Add("infoAsString : {0}", infoAsString)

&

request.Headers.Add(infoAsString)

no joy...please advise

Kevin Brechbühl
  • 4,717
  • 3
  • 24
  • 47
John
  • 3,965
  • 21
  • 77
  • 163

1 Answers1

2

Headers is a NameValueCollection and takes members with a name and a value.

You should be doing

request.Headers.Add("infoAsString", infoAsString)
Ian1971
  • 3,666
  • 7
  • 33
  • 61
  • thanks for the help. I tried this and it seems to work ok (No errors) but when debug going to requestStream.Write(requestBytes, 0, requestBytes.Length);, and the debug jumps over to the server, infoAsString is coming back as NULL....any idea as to why? – John Feb 04 '14 at 12:55
  • Can you post your server code where it tries to read the header? – Ian1971 Feb 05 '14 at 11:03