0

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • web, windows, wpf, silverlight... what is in the origin? in .NET the [`HttpWebRequest`](http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx) does a lot, have you ever look at that? – balexandre Apr 28 '12 at 19:41
  • @balexandre Thanks.. I'm taking look at it . I don't know what you mean by "what is in the origin " ? But MRDS uses .NET framework – user1184061 Apr 28 '12 at 21:11

1 Answers1

0

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();
Mike
  • 71
  • 1
  • 1
  • 3
  • Hi mike , thanks for your reply .I added system.Net to my 'using's but I get an error on request.Close() , it says the WebRequest doesn't contain the definition for that. – user1184061 Apr 28 '12 at 20:56
  • Should I post my data as a string ?? I need to send 'double' value since they are like Ang = 60.0 and Dis = 0.50 . – user1184061 Apr 28 '12 at 22:16