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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:52:27+00:00 2026-06-08T12:52:27+00:00

For a POST request, I got back a response in text/html format and the

  • 0

For a POST request, I got back a response in text/html format and the response body was containing the below info:

oauth_token=XXXXXXXXXXXXXXXXXXXXXXXXX&oauth_token_secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&oauth_callback_confirmed=true

I made this request through System.Net.Http.HttpClient and I throught I could read the response with FormUrlEncodedMediaTypeFormatter as FormDataCollection but it turned out that FormUrlEncodedMediaTypeFormatter only supports application/x-www-form-urlencoded format by default. So, I worked around this with the following code:

using (OAuthHttpClient client = new OAuthHttpClient(creds)) {

    var response = await client.PostAsync(requestUri, new EmptyContent());
    var formatter = new FormUrlEncodedMediaTypeFormatter();
    formatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
    var result = await response.Content.ReadAsAsync<FormDataCollection>(new List<MediaTypeFormatter>() { formatter });

}

The question here is:

Is the response provider (in this case it is Twitter) doing it wrong by sending this response as text/html or should FormUrlEncodedMediaTypeFormatter support text/html type by default?

  • 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-08T12:52:28+00:00Added an answer on June 8, 2026 at 12:52 pm

    Your question is missing some key info i.e. what is the requestUri supposed to return by default, is it a Web API service or an external one etc. It seems it’s not Web API because it’s little odd that it returns “text/html”.

    But the fact that FormUrlEncodedMediaTypeFormatter doesn’t support formatting back from text/html is absolutely fine. Because why would it? “application/x-www-form-urlencoded” is effectively a key-value dictionary and text/html is a rich media type.

    In Web API, with the way content negotiation works, it looks at

    1. Mediatype mappings (I assume not in place in your case)
    2. Accept headers – looking at your request you don’t set them
    3. Request content type – again, looking at your request you don’t set it so it’s empty
    4. Can the formatter serialize a given type

    So if you make the request as you showed to any Web API action, it would return text/xml (if you didn’t tweak conneg manually).

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

Sidebar

Related Questions

I've got a simple PHP script that sends an HTTP POST request via cURL,
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
I have two websites that post news information. I just got a request to
I'm sending an HTTP POST request to a URL. It sends back a piece
I've got an iPhone app sending data to my server with a post request:
I've got a problem using WebClient.UploadStringAsync method. I've to do a POST request with
I've got the following class which makes an HTTP post request asynchronously to avoid
I am making a post request on an Arduino device with the Ethernet shield
I have a POST request coming to one of my pages, here is a
Possible Duplicate: JavaScript post request like a form submit I have a value calculated

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.