Results 1 to 2 of 2

Thread: Setting AllowAutoRedirect = True not working

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2024
    Posts
    2

    Setting AllowAutoRedirect = True not working

    Hi,

    I am trying to get access-token as part of API authentication in vb.net but its throwing status code 308 'Permanent Redirect'.
    I've added AllowAutoRedirect = True to client handler but its still throwing 308

    My code is as follows.

    Dim httpClientHandler As HttpClientHandler = New HttpClientHandler With {
    .AllowAutoRedirect = True,
    .MaxAutomaticRedirections = 1
    }


    Using client As HttpClient = New HttpClient(httpClientHandler)

    Dim request As FormUrlEncodedContent = New FormUrlEncodedContent(New Dictionary(Of String, String) From {
    {"grant_type", "client_credentials"},
    {"client_id", "xxxx"},
    {"client_secret", "xxxx"},
    {"resource", "xxxxx"}
    })

    Dim response As HttpResponseMessage = client.PostAsync(myUrl, request).Result

    I need to allow Auto redirect.

    in postman its working fine when i turn on 'Automatically follow redirects'.

    Can someone please help as I am completely stuck here

    Thanks

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2024
    Posts
    2

    Re: Setting AllowAutoRedirect = True not working

    Hello

    Any one can help

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