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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:54:04+00:00 2026-06-09T16:54:04+00:00

I am trying to do a POST like this: HttpClient hc = new HttpClient();

  • 0

I am trying to do a POST like this:

    HttpClient hc = new HttpClient();
    byte[] bytes = ReadFile(@"my_path");

    var postData = new List<KeyValuePair<string, string>>();
    postData.Add(new KeyValuePair<string, string>("FileName", "001.jpeg"));
    postData.Add(new KeyValuePair<string, string>("ConvertToExtension", ".pdf"));
    postData.Add(new KeyValuePair<string, string>("Content", Convert.ToBase64String(bytes)));

    HttpContent content = new FormUrlEncodedContent(postData);
    hc.PostAsync("url", content).ContinueWith((postTask) => {
    postTask.Result.EnsureSuccessStatusCode();
    });

but I receive this exception:

Invalid URI: The Uri string is too long.

complaining about this line: HttpContent content = new FormUrlEncodedContent(postData);. For small files it works but I don’t understand why for larger ones it doesn’t?

When I do POST the content can be larger…Then why it complains about URI?

  • 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-09T16:54:05+00:00Added an answer on June 9, 2026 at 4:54 pm

    You should use MultipartFormDataContent ( http://msdn.microsoft.com/en-us/library/system.net.http.multipartformdatacontent%28v=vs.110%29 ) instead of FormUrlEncodedContent, which sends your data as “application/x-www-form-urlencoded”.

    So even if your using the POST verb, it is still POSTing to a very long url containing your data, hence the error.

    The content type “application/x-www-form-urlencoded” is inefficient
    for sending large quantities of binary data or text containing
    non-ASCII characters. The content type “multipart/form-data” should be
    used for submitting forms that contain files, non-ASCII data, and
    binary data.

    See : http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1

    For a sample, have a look at this answer : ASP.NET WebApi: how to perform a multipart post with file upload using WebApi HttpClient

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

Sidebar

Related Questions

I'm trying to do something like this post but with Excel VBA. I would
I'm trying to achieve URLs like this in Rails: http://localhost/posts/1234/post-slug-name with both ID and
I'm trying to post with JQuery like this: $.post(NiceController/Create/, { field1: data1, field2: data2
Im trying to create a POST method for my AddTagtoGroup which looks like this
The Post looks like this. $data = array('icd9' => $icd9, 'cpt' => $cpt, 'session_id'=>
I am trying to post json object {venue:places, US} using below code- HttpClient client
I'm trying to post a link + status through my app, using this "popup"
I am trying to post data to the action method in the postData section
I'm trying to post Notifications via AlarmManager delayed. For this purpose I created an
I'm trying to filter out the iframe in my post, my post looks like

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.