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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:03:30+00:00 2026-06-02T22:03:30+00:00

I have followed the HttpClient samples but couldn’t figure it out how to post

  • 0

I have followed the HttpClient samples but couldn’t figure it out how to post a method with 2 parameters.

Below is what I tried but it return bad gateway error:

        private async void Scenario3Start_Click(object sender, RoutedEventArgs e)
    {
        if (!TryUpdateBaseAddress())
        {
            return;
        }

        Scenario3Reset();
        Scenario3OutputText.Text += "In progress";

       string resourceAddress =  "http://music.api.com/api/search_tracks";
        try
        {
            MultipartFormDataContent form = new MultipartFormDataContent();
        //    form.Add(new StringContent(Scenario3PostText.Text), "data");
            form.Add(new StringContent("Beautiful"), "track");
            form.Add(new StringContent("Enimem"), "artist");

            HttpResponseMessage response = await httpClient.PostAsync(resourceAddress, form);
        }
        catch (HttpRequestException hre)
        {
            Scenario3OutputText.Text = hre.ToString();
        }
        catch (Exception ex)
        {
            // For debugging
            Scenario3OutputText.Text = ex.ToString();
        }
    }

I looked all over the internet, but couldn’t find any working examples or documents that show how to perform the http post method. Any materials or samples would help me a lot.

  • 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-02T22:03:31+00:00Added an answer on June 2, 2026 at 10:03 pm

    Try FormUrlEncodedContent instead of MultipartFormDataContent:

    var content = new FormUrlEncodedContent(
        new List<KeyValuePair<string, string>>
        {
            new KeyValuePair<string, string>("track", "Beautiful"),
            new KeyValuePair<string, string>("artist", "Enimem")
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed a gallery tutorial and have it working fine, but the problem
I have followed the instructions and have tried to install simple-private-messages gem for Rails
I have followed the directions laid out in the book entitled Version Control With
I have followed a link http://lukesampson.com/post/315838839/cas-on-windows-localhost-setup-in-5-mins , then the cas server works correctly, the
I have followed the instructions at http://www.javacodegeeks.com/2011/01/advanced-smartgwt-tutorial-part-1.html and tried to create a simple screen
I have followed this tutorial and added iAd to my app: http://bees4honey.com/blog/tutorial/how-to-add-iad-banner-in-iphoneipad-app/ But the
I have followed instructions verbatim using border:none and background:transparent, but a border still shows
I have followed the instructions on the jQuery site to close jQuery tabs but
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I have followed the sample code below to upload a zip file in the

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.