6

我正在尝试使用以下代码将订单发布到 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.

任何帮助是极大的赞赏。

4

1 回答 1

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

希望能帮助到你。

于 2013-12-20T14:44:07.347 回答