C# Post JSON with Authentication Header
07:37 03 Jun 2015

I have problem with post JSON with authentication/Authorization.. Below is my code.. opponent said that they didnt receive the header...and i have no idea why...

ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(stringData);

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serverURL);
req.Method         = "POST";
req.ContentType    = "application/json";
req.ContentLength  = data.Length;
req.Headers.Add("Authentication", merchantID);
req.Headers["Authentication"] = merchantID;

Stream newStream = req.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();

HttpWebResponse response = (HttpWebResponse)req.GetResponse();
string returnString = response.StatusCode.ToString();
c# json post