Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9099857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:43:27+00:00 2026-06-17T00:43:27+00:00

I need to consume a web resource from a VB.NET app. I have successfully

  • 0

I need to consume a web resource from a VB.NET app. I have successfully retrieved the access token and am ready to use it to make calls to the protected resource. However, everytime I call the protected resource I receive a 401 Unauthorized response because the Authorization field has not been added to the header.

Here is my code.

WebRequest = DirectCast(Net.WebRequest.Create(ApiUri), HttpWebRequest)
WebRequest.Method = "POST"
WebRequest.ContentType = "application/json"
WebRequest.ContentLength = Bytes.Length
Dim RequestStream As IO.Stream = WebRequest.GetRequestStream
RequestStream.Write(Bytes, 0, Bytes.Length)
RequestStream.Close()
WebRequest.Headers("Authorization") = "OAuth " & _
                                      "oauth_version=""1.0""," & _
                                      "oauth_nonce=""" & Nonce & """," & _
                                      "oauth_timestamp=""" & TimeStamp & """," & _
                                      "oauth_consumer_key=""" & ConsumerKey & """," & _
                                      "oauth_token=""" & Token & """," & _
                                      "oauth_signature_method=""HMAC-SHA1""," & _
                                      "oauth_signature=""" & Signature & """"
WebResponse = DirectCast(WebRequest.GetResponse(), HttpWebResponse)

I then monitor the request using Fiddler. All I see in Fiddler is the request with the 401 response as shown below (excluding the bodies).

Request

POST ***url*** HTTP/1.0
Content-Type: application/json
Host: ***host***
Content-Length: 45
Connection: Keep-Alive

Response

HTTP/1.0 401 Unauthorized
X-Powered-By: PHP/5.3.13
WWW-Authenticate: Basic realm="***realm***"
Content-type: application/json
Content-Length: 79
Connection: keep-alive
Date: Mon, 07 Jan 2013 01:13:22 GMT
Server: lighttpd/1.4.28

Everywhere I’ve read on the internet indicates that HttpWebRequest should first challenge the server and receive a 401 response as I’m seeing here. It should then try again with the Authorization field added to the header and get the 200 OK response. This second part doesn’t happen. Am I not understanding how this works correctly, or am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:43:28+00:00Added an answer on June 17, 2026 at 12:43 am

    Turns out you need to add the content using a BinaryWriter, not a Stream.

    So instead of this.

    WebRequest.ContentLength = Bytes.Length
    Dim RequestStream As IO.Stream = WebRequest.GetRequestStream
    RequestStream.Write(Bytes, 0, Bytes.Length)
    RequestStream.Close()
    

    Do this.

    Using Writer As New IO.BinaryWriter(WebRequest.GetRequestStream)
        Writer.Write(Bytes)
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to consume a SOAP web service from a C# .Net 4.0 client.
I need to consume web services from a .NET web service and serve up
I need to consume an AXIS 1.4 Web service over SSL from a .NET
I have a web service that I need to consume from BizTalk orchestration. I've
I need to consume a REST web service from my android device. I have
I need to consume a web service from android/eclipse by soap method. ie., i
I have been given a WSDL file and I need to consume a web
I use asp.net 2 and need to consume a 3rd party HTTP GET call
From a .NET application, how do I consume a Web Service developed using gSoap
I need to access a web service from a J2ME application. Any good advice

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.