c# - HttpRequest.GetResponse() taking too much time -
i have outlook addin application i'm connecting salesforce. i'm trying request data sf api returns result in less 1 second, code takes 5-15 seconds complete.
i have tried set proxy null.
here code:
system.net.servicepointmanager.securityprotocol = system.net.securityprotocoltype.tls12; system.net.webrequest req = system.net.webrequest.create(uri); if (includecustomheader == true) { req.headers.add("authorization: oauth " + servicemanager.token.access_token); req.headers.add("x-prettyprint:1"); req.contenttype = "application/json"; } else { req.contenttype = "application/x-www-form-urlencoded"; } req.method = "post"; req.proxy = null; byte[] data = system.text.encoding.ascii.getbytes(payload); req.contentlength = data.length; using (var responsestream = req.getrequeststream()) { responsestream.write(data, 0, data.length); } //here it's taking 5-15 seconds, each request gets batch of 200 records using (var response = req.getresponse()) { return new system.io.streamreader(response.getresponsestream()).readtoend(); }
don't know missing , or there other reason? suggestions?
Comments
Post a Comment