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

  • Home
  • SEARCH
  • 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 6573313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:07:00+00:00 2026-05-25T15:07:00+00:00

Below is a code snippet I am using to post data to a REST

  • 0

Below is a code snippet I am using to post data to a REST based server. If I start debugging on the server I am seeing two separate requests come through. What I want to know is why?

My request is failing because of the second call. If I debug it shows the first request is going through fine, but when I try and read the response on the client side it sends over new call to the server and that one fails authentication.

Comments inline below where the 2 calls to the server fire off…

        string requestUri = "/Service/Contacts";

        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(SERVICEBASEURI + requestUri);
        httpWebRequest.Headers.Add(AUTHENTICATE, m_AuthenticationKey);
        httpWebRequest.Headers.Add(UTCTIMESTAMP, m_UtcTime.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'Z'"));
        httpWebRequest.Headers.Add(NONCE, m_NonceValue);
        httpWebRequest.Accept = "*/*";
        httpWebRequest.UserAgent = "Test-Framework";

        httpWebRequest.Method = "POST";

        string postData = "instance={\"FullName\":\"Altonymous\"}";
        byte[] postDataBytes = new ASCIIEncoding().GetBytes(postData);

        // TODO: Add postData to the Payload.  Needs to be done on authorization side as well.
        string requestPayload = GetPayload(requestUri);
        httpWebRequest.Headers.Add(AUTHORIZATION, requestPayload);
        httpWebRequest.ContentType = "application/x-www-form-urlencoded";
        httpWebRequest.ContentLength = postDataBytes.Length;

        Stream stream = httpWebRequest.GetRequestStream();
        // First call fires off to the server.  I didn't expect it to happen here...
        stream.Write(postDataBytes, 0, postDataBytes.Length);
        stream.Close();

        // Second call fires off to the server.  This is where I expected it to happen.
        using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse())
        {
            Assert.AreEqual(HttpStatusCode.OK, httpWebResponse.StatusCode);

            Stream responseStream = httpWebResponse.GetResponseStream();
            StreamReader responseStreamReader = new StreamReader(responseStream);
            string resultString = responseStreamReader.ReadToEnd();
            Assert.IsNotNullOrEmpty(resultString);
        }
  • 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-25T15:07:00+00:00Added an answer on May 25, 2026 at 3:07 pm

    Appears this is a bug in the Microsoft testing design.

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

Sidebar

Related Questions

How to send triimed data using $.get() see code snippet below: $(#txtSearch).keyup(function() { $.get(/controller/method/,
I am using the code snippet below, however it's not working quite as I
I'm trying to POST some multipart form data to my server using a Browser
I'm using the code snippet below to create a JFormattedTextField. When entering values via
I am trying to add two Vectors below is the code snippet :- #include
Objective: I want to send multiple images using multipart/form-data. Below is a snippet of
In the snippet of code below, I'm using the strcasecmp() function. The function works
I am using the below code snippet to get the html string of a
Which code snippet will give better performance? The below code segments were written in
In the below code snippet can i replace char * to const char *

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.