Reputation: 59
How can I send an HttpPost request to the drive service (I'm using the generic diff drive) to set the distance and the rotate angle to a specific value?
I wrote my own service and it works properly without using HttpPost.
What actually is happening is that I get the object position from vision service and calculate a distance and an angle between robot and the object (which doesn't give me the right value yet but it's not important now) and then send them ( angle and distance) on the rotateAngle and driveDistance of the generic drive service. What I want to do is that sending them by HTTP POST message.
Upvotes: 0
Views: 113
Reputation: 71
You can use the System.Net.WebRequest class to perform an HTTP post:
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();
Upvotes: 0