I asked here how to record https and now it works fine. The problem now is how to send the parameter, requesting a name that is a json string:
{"key1": "value1", "key2": {"key21": "val21"}}
What I am doing but not working:
HttpWebRequest q = (HttpWebRequest)WebRequest.Create(Host + ":" + Port);
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
q.Method = "POST";
q.ContentType = "application/json";
q.Headers.Add("JSON-Signature", GetFirma(query));
q.Credentials = new NetworkCredential(user,pass);
byte[] buffer = Encoding.UTF8.GetBytes("query=" + query);
q.ContentLength = buffer.Length;
using (Stream stream = q.GetRequestStream())
{
stream.Write(buffer, 0, buffer.Length);
}
But the server always responds, saying that there is no query parameter. Any help?
Thanks in advance!
source
share