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 7586907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:32:34+00:00 2026-05-30T19:32:34+00:00

If I’m making an OAuth Access Token request for resources of a third party

  • 0

If I’m making an OAuth Access Token request for resources of a third party Api I wraped, to get all customer cases data for example.

There are no querystrings required for this GET since I am just requesting data back, but my question is, do I still need to specify a request stream (byte data) of some sort or just assume that the ContentLength should be left out and is read as -1 by the Request object?

e.g. I don’t have to worry about setting the ContentLength or buffer do I. I just need to use a stream reader to grab the returned .json or whatever the API sends back to me correct?

        HttpWebResponse response;
        Stream dataStream; // data returned from the response
        byte[] buffer = null; // data to send in the request body

        // FYI the "data" variable is just an incoming param to my send method, a string if I want to send data in the request (i.e. json, xml, whatever I am sending if needed)
        if (!string.IsNullOrEmpty(data.Trim())) buffer = Encoding.UTF8.GetBytes(data);

        // the resourceUrl variable I'm specifying for example is "ttp://someThirdPartyApi.com/api/v1/cases.json"
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resourceUrl);

       // I then add an authorization header to the resonse.Headers (not shown here)

        request.ServicePoint.Expect100Continue = false;
        request.PreAuthenticate = true;

        // do we have any data to send in the request -body-??
        if (buffer != null && buffer.Any())
        {
            request.ContentLength = buffer.Length;

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(buffer, 0, buffer.Length);
                stream.Close();
            }
        }

        // no data to send, just get the data returned in the response using a StreamReader
  • 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-05-30T19:32:35+00:00Added an answer on May 30, 2026 at 7:32 pm

    Unless you’re actually posting data, you don’t need to do anything with the request stream. Depending on what you’re doing, you might even be able to use WebClient and its DownloadString() method, and avoid a lot of the extra code involved in using the lower-level WebRequest, etc.

    Of course, you lose some control and flexibility, but maybe you don’t need that if it’s a simple API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a text area in my form which accepts all possible characters from
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.