c# - Request Timed Out error when JSon Call -


i've created json object newtonsoft. when want pass restful webservice , want response it, "request timed out" error, although set timeout request -1 or any. can problem?

httpwebrequest request = (httpwebrequest)webrequest.create("https://app.myservice.com/sendjson");     request.contenttype = "text/json";     request.method = "post";     request.timeout = 200000;      jobject asninfo = createasninfo();      jsonserializer serializer = new jsonserializer();     using (var streamwriter = new streamwriter(request.getrequeststream()))     {         using (var writer = new jsontextwriter(streamwriter))         {             serializer.serialize(writer, asninfo);         }     }     var response = (httpwebresponse)request.getresponse();     using (var streamreader = new streamreader(response.getresponsestream()))     {         var responsetext = streamreader.readtoend();     } 

are behind proxy? code seems work public test web service.

link .net fiddle working example

using system; using system.io; using system.net; using newtonsoft.json; using newtonsoft.json.linq;  public class program {     public static void main()     {         httpwebrequest request = (httpwebrequest)webrequest.create("http://jsonplaceholder.typicode.com/posts");         request.contenttype = "text/json";         request.method = "post";         request.timeout = 200000;          jobject asninfo = jobject.parse(@"{ title: 'foo', body: 'bar', userid: 1 }");          jsonserializer serializer = new jsonserializer();          using (var streamwriter = new streamwriter(request.getrequeststream()))         {             using (var writer = new jsontextwriter(streamwriter))             {                 serializer.serialize(writer, asninfo);             }         }          var response = (httpwebresponse)request.getresponse();          using (var streamreader = new streamreader(response.getresponsestream()))         {             var responsetext = streamreader.readtoend();              console.writeline(responsetext);         }     } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -