Results 1 to 4 of 4

Thread: httprequest Post Times out.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2011
    Posts
    23

    httprequest Post Times out.

    Hi, I'm trying to do an HTTP Post Request. The user guide says I should send this

    My code keep timing out. I'm not sure if I'm making the request correctly.



    Here's the code [at bottom] I'm trying. Keeping in mind I don't use HTTP request much. I usually do vb.net vb desktop dev.
    I've been struggling with this off and on for many hours and would appreciate any help or samples.


    Code:
    //line breaks for legibility only
    
    POST /ca4f5969-c10f-40d4-8127-e74b691f95de/oauth2/v2.0/token HTTP/1.1
    Host: login.microsoftonline.com
    Content-Type: application/x-www-form-urlencoded
    
    client_id=3c29446e-153e-4b92-8f06-c453f117b645
    &client_secret=3e04~5e12339444d1852d73bb33e9.3cf2
    &grant_type=client_credentials
    &scope=https://tffproduction.onmicrosoft.com/f06cb173-a8e6-44ad-89a1-06c1070a1f62/.default

    Code:
            Dim uri As String = ("https://login.microsoftonline.com/ca4f5969-c10f-40d4-8127-e74b691f95de/oauth2/v2.0/authorize?")
            Dim Req As WebRequest = WebRequest.Create(Uri)
    
    
            Req.Headers.Add("client_id", "4e502cbc-a55f-4341-a498-69cfbe19ee7b")
            Req.Headers.Add("&clientSecret", "Pe48Q~cFymJUFQxw7oTy_eCgQqBUdlG_KifyOcY6")
            Req.Headers.Add("&grant_type", "client_credentials")
            Req.Headers.Add("&scope", "https://tffproduction.onmicrosoft.com/f06cb173-a8e6-44ad-89a1-06c1070a1f62/.default")
            Req.ContentType = ("application/x-www-form-urlencoded")
            Req.Method = ("POST")
    
    
            Dim response = Req.GetResponse().GetResponseStream()
            Dim reader As New StreamReader(response)
            Dim res = reader.ReadToEnd()
            reader.Close()
            response.Close()

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,322

    Re: httprequest Post Times out.

    How long is the timeout period, and does it seem reasonable to you? If you get the timeout quick, and expect to take longer, then that would be unreasonable. If you get the timeout eventually, and expect to connect quickly, that would be unreasonable.

    There is a way to increase the timeout interval, but doing so won't help if waiting long enough doesn't seem likely to be the problem.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2011
    Posts
    23

    Re: httprequest Post Times out.

    Quote Originally Posted by Shaggy Hiker View Post
    How long is the timeout period, and does it seem reasonable to you? If you get the timeout quick, and expect to take longer, then that would be unreasonable. If you get the timeout eventually, and expect to connect quickly, that would be unreasonable.

    There is a way to increase the timeout interval, but doing so won't help if waiting long enough doesn't seem likely to be the problem.
    Yes I can increase it. Perhaps I should have phrased my question better.

    Does the code look correct? I'm not sure what I'm doing . Trying to learn it.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2011
    Posts
    23

    Re: httprequest Post Times out.

    I issue was cause by a NAT that consolidated my household IP's and farmed it out on one address. I'= use starlink for an ISP. When I pulled thier cable and switchd over to my Iphone hot spot everything worked fine. Sigh.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width