HttpWebRequest needs to wait 5 seconds to work properly in PUT method

I am trying to use an API and I don't have any problems with GET and POST but PUT isn't working. I tried with a lot of different examples and finally by chance I discovered that waiting more that 5 seconds (with 5000ms it is not working and with 5100ms it does)
it starts working properly. But why is that happening? And how can I avoid this? 5 seconds for each registry update is to much waiting and I really don't understand why POST works well without waiting and PUT needs 5 seconds to work.
Here I put the method that I am using with the Thread.Sleep(5100).
As I said without this line when I make WebResponse
response = request.GetResponse(); gives me an error.
public void call(string url, object jsonObj)
try
// Create a request using a URL that can receive a post.
HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(urlSplio);
// Create POST data and convert it to a byte array.
request.Method = "PUT";
// Set the ContentType property of the WebRequest.
request.ContentType = "application/json";
request.Credentials = new NetworkCredential(WebConfigurationManager.AppSettings["User"], "WebConfigurationManager.AppSettings["Key"]");
string json = JsonConvert.SerializeObject(jsonObj);
byte[] byteArray = Encoding.UTF8.GetBytes(json);
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
Thread.Sleep(5100);
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Display the content.
Console.WriteLine(responseFromServer);
// Clean up the streams.
dataStream.Close();
response.Close();
catch (Exception ex)

Perhaps there are some artificial delays, such as Thread.Sleep(5000), accidentally left in the provider’s code for testing purposes.
In some of technologies, the server functions should have certain special attributes, such as [WebInvoke(Method = "PUT")]. Check if this is the case, with providers.

Similar Messages

  • The problem related to wireless service Wi-Fi connectivity Never work properly

    Hi
    i am bashair from KSA
    I have iPhone 5, you update your iPhone to version 6.1.3
    The problem related to wireless service Wi-Fi connectivity
    Never work properly, you try Method posed but did not succeed..
    i need help me please
    thanks..

    UPDATE
    Hey this is totally weird. I haven't done jailbreak at all and I won't But how is possible that default apps such as Safari and Appstore have the problem I've mentioned before and Skyfire works perfectly without any trouble.
    So to sum up:
    Safari: loading stucks after few seconds on wi-fi, mostly doesn't load pictures
    Appstore: loading stucks after few seconds on wifi and it keeps saying "loading"
    Facebook and Youtube: doesn't load pictures
    SKYFIRE: loads everything without any trouble
    and completely everything works on Edge...
    So tell me W.T.F. :-D

  • Need to get graphics to work on HP Envy 17t-3000 CTO

    Please bear with me. I'm not very tech savvy but am great at following directions to solve problems.
    I received a used HP Envy 17t-3000 CTO laptop with 750 GB...i7 - 2670 QM...6GB...64 Bit. with no restore on it to get back to original config.
    I received it updated to Windows 8.1 Pro which didn't allow video drivers to work (Intel HDGraphics 3000 and AMD 7690M XT switchable graphics).
    I installed Windows 7 Home Premium back on it (originally on it when made) from an ISO download on line.
    My problem is that I need to know exactly what drivers in which order to download on top of Win 7 install to get switchable graphics display to work as it's still not working with 8.1 Pro removed. I currently have a black screen and only see the screen with HDMI connected to the tv.
    I need to be sure I am downloading all the needed drivers for it to work properly ASAP as I have a time limit to return it if that isn't the problem / isn't fixable / is a hardware problem.
    I really want to keep it if it is fixable with correct driver installations and I don't have time to order restore disc from HP before my return window is closed.
    So, can someone please help me and list the drivers in order of installation for my laptop?
    Thanks!
    PS: When I reinstall Windows 7 Home Premium from my burned ISO file does that remove all the drivers I tried to install before that aren't working? If not...how do I do that? I want to start over beginning with the Win 7 install followed by the correct drivers in correct order....back to original config.

    Hi,
    Same post as:
       http://h30434.www3.hp.com/t5/Notebook-Operating-Systems-and-Software/Need-to-get-graphics-to-work-on...
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • I am new to mac air. Today i installed (unsuccessfully!) MAPLE16 on my mac book air. Now since it does not work properly (it also does not appear in  applications) i decide to delete it. I could not remove it from launchpad . i need urgent help

    i am new to mac air. Today i installed (unsuccessfully!) MAPLE16 on my mac book air. Now since it does not work properly (it also does not appear in  applications) i decide to delete it. I could not remove it from launchpad . i need urgent help from your side.

    Any third-party software that doesn't install by drag-and-drop into the Applications folder, and uninstall by drag-and-drop to the Trash, is a system modification.
    Whenever you remove system modifications, they must be removed completely, and the only way to do that is to use the uninstallation tool, if any, provided by the developers, or to follow their instructions. If the software has been incompletely removed, you may have to re-download or even reinstall it in order to finish the job.
    I never install system modifications myself, and I don't know how to uninstall them. You'll have to do your own research to find that information.
    Here are some general guidelines to get you started. Suppose you want to remove something called “BrickMyMac” (a hypothetical example.) First, consult the product's Help menu, if there is one, for instructions. Finding none there, look on the developer's website, say www.brickmyrmac.com. (That may not be the actual name of the site; if necessary, search the Web for the product name.) If you don’t find anything on the website or in your search, contact the developer. While you're waiting for a response, download BrickMyMac.dmg and open it. There may be an application in there such as “Uninstall BrickMyMac.” If not, open “BrickMyMac.pkg” and look for an Uninstall button.
    You generally have to reboot in order to complete an uninstallation.
    If you can’t remove software in any other way, you’ll have to erase and install OS X. Never install any third-party software unless you're sure you know how to uninstall it; otherwise you may create problems that are very hard to solve.
    You may be advised by others to try to remove complex system modifications by hunting for files by name, or by running "utilities" that purport to remove software. I don't give such advice. Those tactics often will not work and maymake the problem worse.

  • HT1267 My iPod player in my iPhone isn't working properly it will play for a few seconds then stop and also the volume level will appear then disappear what can I do to remedy this?

    My iPod player within my iPhone isn't working properly when playing videos it will start then stop after a few seconds and also the sound bar appears then disappears, and when playing music no sound is coming out when I'm on a call I can hear everything properly and also on loud speaker! What can I do to remedy this? Please help!!!

    If you haven't tried it yet, I'd eliminate memory issues first.  Close all of the apps with the double tap on the home button method
    http://support.apple.com/kb/HT5137
    then restart the device.
    http://support.apple.com/kb/HT1430
    My experience has been that this fixes a lot of issues.

  • Clip inspector in imovie not working properly - when I select a picture - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and in a clip the audio adjustment only shows a speaker? help

    Clip inspector in imovie not working properly - when I select a picture (in project library) - and select clip adjustment it tells me that I need to select one or more clips to view Inspector tools and when I select a movie clip and then click on audio adjustments the audio adjustment appears as a speaker icon and I don't know how to get to the various audio options? It was working fine one minute and then I seemed to lose the functionality. Also editing a photo in a photo or getting rid of ken burns effect etc does not seem to work. help

    Can anyone shed any light on this as I am having the same problem? One minute it works fine, the next you get the error message above.
    Many thanks.

  • I purchased the gaming app from app store and I used it for some time but now suddenly the app is not working properly it's not starting properly and just dies down after the start and comes Back to homepage need help please guys help me out with this!

    Guys needed your help with my real racingHD game app it's not working properly even after paying for it I don't know why it's not working having trouble with it cause it won't star smooth need help guys

    Read Mitch's post on the sad ipod in this thread:
    http://discussions.apple.com/message.jspa?messageID=2369954#2369954

  • My iphone 5 sleep button doesnt work properly. Need help where can i get it fixed

    I bought my i5 in january from croma, delhi and last 5-6 days i am noticing that my sleep button is not working properly on the right side. I searched for solution on the net but all i got to know that this is a problem in iphone 5 and need to be replaced. And i have no idea how to get it fixed or where to contact to get it replaced. Need urgent help.
    Thanx in advance

    modular747 wrote:
    It means that for one year from the data of purchase, Apple will replace the phone with a refubished unit for any malfunction not due to abuse or physical damage (i.e dropping, exposure to water, etc,)
    To be clear, it's a new or refurbished unit, whichever Apple has in the replacement phone stream.

  • Do I need to enter my home ISP details into my iPAD to make it work properly .

    Do I need to enter my home ISP into my new iPad to make it work properly ?

    iPads are connected to computers with iTunes to synchronize music, pictures, books etc.
    You typically connect the ipad via wifi to the Internet so that you get the most out of it.
    You should get a wifi/router.

  • Headphones not working properly, i need to contact apple

    Hi! My headphones are not working properly and I need to request new ones from Apple but I do not know how to contact them through e-mail, I couldnt find such an option in the support pages, I also need to ask them an issue about my warranty. I can not use the chat help option because somehow I can only select ipod shuffle and i do not even have it, why are chat pages only for ipod shuffle? Anyway, I'll be glad if somebody tells me what to do to contact them by mail. Thanks!

    There is no email tech support, for new headphones you fill out a service request.
    You can arrange online service here.
    Service request.
    To check the status of your warranty, go here.
    http://www.apple.com/support/

  • I manage 60 ipads for a school using Apple Configurator. Need to update to iOS7 and AC1.4.3...Is it best to use Mountain Lion or Mavericks, as I also need to update from Lion 10.7 for the new AC and iOS to work properly.

    I manage 60 ipads for a school using Apple Configurator. Need to update my devices to iOS7 and Apple Configurator to 1.4.3...Is it best to use Mountain Lion or Mavericks, as I also need to update from Lion 10.7 for the new Apple Configurator and iOS7 to work properly.

    I always run a Time Machine backup before updating anything and recommend you run a backup as well. Paid apps should migrate over without any problem. If you have problems with VPP codes not transfering over properly, you can talk to your Apple SE or contact VPP for Education support and they can help you. While I haven't experienced any problems with updating, its never a guarantee that others will have the same experience.
    Good luck!
    ~Joe

  • Button dosen't work properly, need help please

         In a custom component I have 5 buttons, for each button i have the roll over, roll out and on click Interaction
    So if you roll your mouse pointer on a button it transitions to a state that looks the same but a picture pops out and if i roll out in transitions back
    to the first state within the custom component. Every thing works properly except the "on click" interaction: when I click on the button it briefly
    transitions to the state it needs to (a totally different one, within the custom component) then it comes back to the original state within custom component
    I played around with the "when in state" button but I can't get a crack at it, please help me and ask anything you need if I my explanation wasn't clear enough

    Sounds like you might have an interaction misapplied to some part of the component. I would look around for a rogue On Click interaction, and also look at what the Pressed states look like of the button.
    Chris

  • TS1398 my iphone 4s can not scan any wifi network, i tried everything but still can not scan any wifi connection even though our wifi is working properly in our mac book and ipad. What do i need to do if the problem is the hardware?pls help

    my iphone 4s can not scan any wifi network, i tried everything but still can not scan any wifi connection even though our wifi is working properly in our mac book and ipad. What do i need to do if the problem is the hardware?pls help

    When you say it "can not scan any wifi network" do you mean it is not detecting Wi-Fi networks?
    Is Wi-Fi turned on in Settings > General > Wi-Fi?
    Have you tried Settings > General > Reset > Reset Network Settings?
    Is it just the home network that the device will not connect to? or any network?

  • What is the Firewall ports need to be open for TED distribution working properly

    Hi ,
    May I know what ports need to be open at the firewall in order the TED
    distribution to be working properly.
    I suspect it is firewall problem because the inventoried server which
    is install at the same segment with the TED distributor server, I manage to
    push the policy and collect inventory data , but for those inventoried
    server which is install at the remote site, I fail to push the TED into the
    server. At the TED distributor server, the log say that computer refused
    connection. And there is a firewall in between the TED distributor server
    and the remote inventoried server.
    Thank you.
    Steven Foong

    TED is using 1229
    Ron
    <[email protected]> wrote in message
    news:X7lAe.2193$[email protected]..
    > Hi ,
    >
    > May I know what ports need to be open at the firewall in order the
    TED
    > distribution to be working properly.
    >
    > I suspect it is firewall problem because the inventoried server which
    > is install at the same segment with the TED distributor server, I manage
    to
    > push the policy and collect inventory data , but for those inventoried
    > server which is install at the remote site, I fail to push the TED into
    the
    > server. At the TED distributor server, the log say that computer refused
    > connection. And there is a firewall in between the TED distributor server
    > and the remote inventoried server.
    >
    > Thank you.
    >
    >
    > Steven Foong

  • Which ports need to be open for messages and facetime to work properly?

    I noticed that Messages no longer works since upgrading to Yosemite on my work network. But it did when i was in Mavericks. Did they change something in Messages in the upgrade that would cause it to no longer work? ports?
    I'm behind my work firewall, which ports need to be open for messages to work properly?

    Just make sure your 9001 port is open.
    Hope this works..
    Hamid

Maybe you are looking for

  • Portal application not displaying correctly with frame size 125% in IE

    Dear Expert, We are facing issue in Portal (7.0) like, when I open the application "Products Coatings" in myWorkspace with Internet Explorer display size 100% the frame "xyz" is displayed correctly:But When I open the application "Product Coatings" i

  • Unable to download Sun Java System Identity Synchronization for Windows

    Please any one can help me How can i download Sun Java System Identity Synchronization for Windows * Sun Java System Directory Server ---------------------able to download * Sun Java System Directory Proxy Server --------------able to download * Sun

  • IPhoto 11 smaller resolution?

    After I imported my entire library from a back up (migrating to new iMac) I noticed that every photo in that library is now low resolution (It down rezzed every photo in my library) and the full res version doesn't appear to exist anywhere on my new

  • Accessing the KM Respository through Portal Code.

    Hi, I am New to Portal development. I want to Access the KM Repository through AbstractPortalComponent. Plz Reply ASAP with code. Thanks and Regards Kiran

  • Photos for mac problems

    I can't believe there's no similar questions on here...! Well, after 'upgrading' I've run into problems/glitches and annoyances. Loading photos from my memory card works fine, and I mostly like the upgrade. But my Macbook pro retina- new three months