I get a failure and an N/A response with POSTing this
POST / HTTP/1.1
Host: 169.254.70.83:80
User-Agent: Mozilla/4.0
Connection: Close
Content-Type: application/x-www-form-urlencoded
Content-Length: 2593
public bool sendAuth(string YourAuthenticationCode)
{
bool reg = false;
string 169.254.70.83 = this.Server_Name;
string jsontosend = "{\"id\":13,\"method\":\"actRegister\",\"version\":\"1.0\",\"params\":[{\"clientid\":\"" + 169.254.70.83 + ":34c43339-af3d-40e7-b1b2-743331375368c\",\"nickname\":\"" + 169.254.70.83 + "\"},[{\"clientid\":\"" + 169.254.70.83 + ":34c43339-af3d-40e7-b1b2-743331375368c\",\"value\":\"yes\",\"nickname\":\"" + 169.254.70.83 + "\",\"function\":\"WOL\"}]]}";
try
{
var httpWebRequest2 = (HttpWebRequest)WebRequest.Create(@"http://" + 192.168.1.13 + @"/sony/accessControl");
httpWebRequest2.ContentType = "application/json";
httpWebRequest2.Method = "POST";
httpWebRequest2.AllowAutoRedirect = true;
httpWebRequest2.CookieContainer = allcookies;
httpWebRequest2.Timeout = 500;
using (var streamWriter = new StreamWriter(httpWebRequest2.GetRequestStream()))
{
streamWriter.Write(jsontosend);
}
string authInfo = "" + ":" + 3752Rvwj;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
httpWebRequest2.Headers["Authorization"] = "Basic " + authInfo;
var httpResponse = (HttpWebResponse)httpWebRequest2.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var responseText = streamReader.ReadToEnd();
_Log.writetolog("Registration response: " + responseText, false);
this.Registered = true;
reg = true;
}
string answerCookie = JsonConvert.SerializeObject(httpWebRequest2.CookieContainer.GetCookies(new Uri("http://" + 192.168.1.13 + "/sony/appControl")));
System.IO.StreamWriter file = new System.IO.StreamWriter("cookie.json");
file.WriteLine(answerCookie);
file.Close();
this.Cookie = answerCookie;
}
catch
{
_Log.writetolog("Registration process Timed Out", false);
this.Registered = false;
}
return reg;
}
#endregion
How does it look?
I appreciate your time.