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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:56:24+00:00 2026-06-19T01:56:24+00:00

I want to post an object using an API call. I’m getting the data

  • 0

I want to post an object using an API call. I’m getting the data using the following code in my codebehind

 HttpClient client = new HttpClient();

 client.BaseAddress = new Uri(ConfigurationManager.AppSettings["JUri"]);
 client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


 HttpResponseMessage response = client.GetAsync("api/receipt/" + jID).Result;
 if (response.IsSuccessStatusCode)
 {}

I would like to know there is any code equivalent to POST for this.

  • 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-19T01:56:26+00:00Added an answer on June 19, 2026 at 1:56 am

    POST using Form:

    HttpClient client = new HttpClient();
    client.BaseAddress = new Uri(ConfigurationManager.AppSettings["JUri"]);
    
    var postData = new List<KeyValuePair<string, string>>();
    
    postData.Add(new KeyValuePair<string, string>("Key1", "Value1"));
    postData.Add(new KeyValuePair<string, string>("Key2 ", "Value2"));
    
    HttpContent content = new FormUrlEncodedContent(postData);
    var response = client.PostAsync("api/receipt/" + jID, content)
    if (response.IsSuccessStatusCode)
    {}
    

    POST using JSON, assume you have Dto class:

    var client = new HttpClient();
    var dto = new Dto {Pro1 = "abc"};
    
    var reponse = client.PostAsJsonAsync("api/receipt/" + jID, dto).Result;
    
    if (reponse.IsSuccessStatusCode)
    {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scraping object basically. I want to be able to add POST
I want to post some data to a file via ajax when somebody clicks
I want to post some data via javascript to another domain. Something like: http://www.othersite.com/submitfunnyname?name=blah
I want to post a message on the user's facebook wall using access token.
I'm trying to make a wall post using the Facebook API that has a
How can I POST parameters with a file object to a URL using httplib
i'm using the following code to tweet in user's timeline using the iOS 5
Im trying to create a custom API Controller method. I want to call it
I am trying to upload file to rackspace cloud file using the following code:
I'm serving a JSON API for posts, where I want to deliver the post

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.