user2545071
user2545071

Reputation: 1410

c# rest client example

Good day!

I am new at REST api, use SOAP only (with auto-generated Visual Studio SOAP proxy client).

So, now I have a foreign system with REST-requests.

At this documentation they says that -server that handles REST requests goes to- http:///ws.

And all services addresses at- "http : //server_uri:port/WSserver/ws".

So I write simple code:

 string uri = "http:/localhost:8000/WSserver/ws/newsession";
  HttpWebRequest req = WebRequest.Create(uri) as HttpWebRequest;
        req.KeepAlive = false;
        req.ContentLength = 0;
        req.ContentType = "text/xml";

        Stream data = req.GetRequestStream();
        data.Close();

But I get UrlFormatxception with wrong URL-address-cannot parse Authority/Host. So, how to use simple request to it? Can you tell some examples? Thank you!

Upvotes: 0

Views: 964

Answers (1)

user2545071
user2545071

Reputation: 1410

The protocol has a typo. "http:/localhost" is missing the second '/' and should be

http://localhost

Upvotes: 1

Related Questions