☰
Login
Signup
Home
›
General
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Register
Categories
Recent Discussions
Activity
Categories
13.8K
All Categories
0
Incidents
154
Node JS client
40
Go client
793
.Net API client
378
Kite Publisher
537
.Net / VBA / Excel (3rd party)
457
Algorithms and Strategies
993
Java client
1.1K
API clients
404
PHP client
4K
Python client
346
Mobile and Desktop apps
1.4K
Market data (WebSockets)
3.3K
General
In this Discussion
June 2016
sthapatiinfo
June 2016
Kailash
system.net.webexception ASP.NET
sthapatiinfo
June 2016
in
General
After user enters login information with answers etc....it redirects to correct URL and we have posted back api+token+secret SHA256 but it gives following error...
System.Net.WebException The Remote Server Returned 403 Forbidden
Kailash
June 2016
Please share the exact parameters you are sending and the JSON error response you're getting.
sthapatiinfo
June 2016
here is the complete code in asp.net, here you go..
public void Authenticationtemp()
{
string url = "
https://api.kite.trade/session/token
";
var postData = "api_key=" + apikey + "&request_token=" + rqtoken + "&checksum=" + checksum;
byte[] data = Encoding.UTF8.GetBytes(postData);// Encoding.ASCII.GetBytes(postData);
lbl3.Text = url;
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);
}
}
sthapatiinfo
June 2016
in above code GetResponseStream giving 403 forbidden. Let us know when we are making mistake..thanks
Kailash
June 2016
How are you computing the checksum? Can you share that bit?
sthapatiinfo
June 2016
Yes,
public void sha256_hash()
{
string value = apikey + rqtoken + apisecretkey;
StringBuilder Sb = new StringBuilder();
using (SHA256 hash = SHA256Managed.Create())
{
Encoding enc = Encoding.UTF8;
Byte[] result = hash.ComputeHash(enc.GetBytes(value));
foreach (Byte b in result)
Sb.Append(b.ToString("x2"));
}
checksum = Sb.ToString();
}
Kailash
June 2016
@sthapatiinfo
Your app is 'Publisher' which doesn't support APIs. You should create a "Connect" app.
Sign In
or
Register
to comment.
public void Authenticationtemp()
{
string url = "https://api.kite.trade/session/token";
var postData = "api_key=" + apikey + "&request_token=" + rqtoken + "&checksum=" + checksum;
byte[] data = Encoding.UTF8.GetBytes(postData);// Encoding.ASCII.GetBytes(postData);
lbl3.Text = url;
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);
}
}
public void sha256_hash()
{
string value = apikey + rqtoken + apisecretkey;
StringBuilder Sb = new StringBuilder();
using (SHA256 hash = SHA256Managed.Create())
{
Encoding enc = Encoding.UTF8;
Byte[] result = hash.ComputeHash(enc.GetBytes(value));
foreach (Byte b in result)
Sb.Append(b.ToString("x2"));
}
checksum = Sb.ToString();
}