我正在尝试使用以下代码将订单发布到REST API:
string URI = "https://api.myTrade.com/s1/order/" + orderId;
string myParameters = "symbol=AAPL&duration=day&side=buy&quantity=1&type=limit&price=1";
Console.Write("Parameters : " + myParameters + "\n");
using (WebClient wc = new WebClient())
{
wc.Headers[HttpRequestHeader.Authorization] = "Bearer " + token
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.Headers[HttpRequestHeader.Accept] = "application/json";
string responsebody = wc.UploadString(URI, myParameters);
//Console.Write("Output : " + responsebody + " ");
dynamic dynObj = JsonConvert.DeserializeObject(responsebody);
return responsebody;
}
我收到以下异常:
Input String was not in a correct format.
非常感谢任何帮助。
答案 0 :(得分:1)
应该有一个
在参数'字符串之前的orderId之后。还可以尝试URL编码
http://msdn.microsoft.com/en-us/library/system.web.httputility.urlencode(v=vs.110).aspx
和
http://msdn.microsoft.com/en-us/library/zttxte6w(v=vs.110).aspx
希望它有所帮助。