我需要从Ninja Trader到Interactive Broker的API C#执行JSON CSharp Post,使用以下内容:
{
"Instrument": "SIE",
"Side": "BUY",
"Volume": "200",
"Price": "100",
"Type": "LMT",
"Accounts": ["DU1107110", "DU1107170", "DU1107180", "DU1107190"],
"Currency": "EUR",
"Exchange": "SMART",
"SecType": "STK",
"PrimaryExch": "",
"Gives you": ""
}
2条答案
按热度按时间wkyowqbh1#
你需要首先使用数据创建一个C#对象。然后你需要序列化这个对象例如var json = JsonConvert.SerializeObject(data);
现在你需要做的就是将字符串传递给post方法。
var stringContent = new StringContent(json,UnicodeEncoding.Utf8,“application/json”);
var client = new HttpClient(); var response = await client.PostAsync(uri,stringContent);
soat7uwm2#
非常感谢!我能够做到这一点:
/-———————————————————-/