如何将 HttpPost 消息发送到 MRDS 的云端硬盘服务



如何向驱动器服务(我使用的是通用差异驱动器)发送 HttpPost 请求以将距离和旋转角度设置为特定值?

我编写了自己的服务,它在不使用 HttpPost 的情况下正常工作。

实际发生的是,我从视觉服务中获取对象位置,并计算机器人和对象之间的距离和角度(这还没有给我正确的值,但现在并不重要),然后将它们(角度和距离)发送到通用驱动器服务的旋转角度和驱动器距离上。我想做的是通过HTTP POST消息发送它们。

您可以使用 System.Net.WebRequest 类来执行 HTTP 发布:

string postData = "Put your post data here";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
WebRequest request = WebRequest.Create("http://www.mysite.com/PostHere");
request.Method = "POST";
request.ContentLength = byteArray.Length;
request.ContentType = "application/x-www-form-urlencoded";
Stream dataStream = request.GetRequestStream ();
dataStream.Write (byteArray, 0, byteArray.Length);
dataStream.Close ();
request.Close();

相关内容

最新更新