{"The remote server returned an error: (403) Forbidden."}

cdesai1987
Hi ,

I am getting the error (403) Forbidden."} . Please suggest . & Its A Connect App
 var apikey = "XXX";
var rqtoken = "XXX";
var apisecretkey = "XXX";
var checksum = "";

Byte[] byteArray = Encoding.UTF8.GetBytes(apikey + rqtoken + apisecretkey);

SHA256 myHash = SHA256Managed.Create();
Byte[] hashedByteArray = myHash.ComputeHash(byteArray);
StringBuilder Sb = new StringBuilder();
foreach (Byte b in hashedByteArray)
Sb.Append(b.ToString("x2"));
string checksumString = Sb.ToString();

string url = "https://api.kite.trade/session/token";
var postData = "api_key=" + apikey + "&request_token=" + rqtoken + "&checksum=" + checksumString;

byte[] data = Encoding.UTF8.GetBytes(postData);// Encoding.ASCII.GetBytes(postData);


try
{

var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json; charset=UTF-8";
request.ContentLength = data.Length;

using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}

var response = (HttpWebResponse)request.GetResponse();

var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Response.Write(responseString);
}
catch (Exception ex)
{
Response.Write(ex);
}
Sign In or Register to comment.