Chase Florell
Chase Florell

Reputation: 47387

Send HTTP Command using VB.NET

I'm trying to send an HTTP command using VB.NET and I'm not quite sure how to do it. I don't want to actually navigate to the page, just execute the command.

http://xbmc.local/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary%28video%29

What I'm doing is building an integrated interface for my XBMC home theater, and my home automation.

Upvotes: 4

Views: 3553

Answers (2)

womp
womp

Reputation: 116977

You can use the WebRequest object to send an HTTP Request.

' Create a WebRequest object with the specified url. ' 
Dim myWebRequest As WebRequest = WebRequest.Create(url)

' Send the WebRequest and wait for response. ' 
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()

The WebResponse class has a number of properties you can check to see if the request succeeded or not. And just something to be aware of, GetResponse() will throw an exception if it times out.

Upvotes: 2

JaredPar
JaredPar

Reputation: 754853

Try the following

Dim client = WebRequest.Create("http://xbmc.local/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.updatelibrary%28video%29")
Dim response = client.GetResponse()

Upvotes: 1

Related Questions