I am trying to use the new IBKR Client Portal API. I have written a simple console program to access the API but it results in Error 403 - Access denied. If I try the same request from Postman it seems to be working. I tried using fiddler to see the request that console app sends but that results in a separate error. How can I diagnose this issue?
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var baseURL = "https://localhost:5000/v1/portal";
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var client = new HttpClient(handler);
client.DefaultRequestHeaders.Add("Cookie", "ibkr.il = 123456789.123456.0000");
client.DefaultRequestHeaders.Add("AcceptEncoding", "gzip, deflate, br");
var response = await client.GetAsync(baseURL + "/sso/validate");
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}