0

i'm new in web services, i have created a web service that works fine using postman, i can make requests and see the response, however if i use the same url with the same verb in an application, i get the following error: error 10061 connection refused

the code that makes the call for the service is:

            var httpWebRequest = (HttpWebRequest)WebRequest.Create(strUrl);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"user\":\"test\"," +
                              "\"password\":\"bla\"}";

                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }

what´s missing?

Update: this is an image with the succesfull response in postman Get Verb with json body

Post Verb with json body, just as is in code

What would be the problem?

Thank's in advance

SOLVED, i've found solution here: Xamarin: Connect to locally hosted web service

Richard
  • 1
  • 1
  • Please take a look at this: https://stackoverflow.com/questions/4015324/how-to-make-http-post-web-request – Lutti Coelho Dec 17 '19 at 17:10
  • Does this answer your question? [How to make HTTP POST web request](https://stackoverflow.com/questions/4015324/how-to-make-http-post-web-request) – Lutti Coelho Dec 17 '19 at 17:10
  • Thanks Lutti Coelho, but the problem is not the verb, no matter which ona i use always get the connection refused error, i've added new images that show how in postman the response is successfull, and in the code i get error. – Richard Dec 17 '19 at 17:42
  • Can you share the URL you are trying to post? – Lutti Coelho Dec 17 '19 at 18:08

0 Answers0