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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:36:28+00:00 2026-06-12T08:36:28+00:00

I am invoking ASP .Net Web API using HttpClient and invoke actions successfully. Also

  • 0

I am invoking ASP .Net Web API using HttpClient and invoke actions successfully. Also I am able to POST custom object into action as well.

Now problem I am facing is, not able to post scalar data type like Integer,String etc…

Below is my controller and application code that invokes action

// Test application that invoke

[Test]
        public void RemoveCategory()
        {
            HttpClient client = new HttpClient();

            HttpRequestMessage request = new HttpRequestMessage();

            HttpResponseMessage response = client.PostAsJsonAsync<string>("http://localhost:49931/api/Supplier/RemoveCategory/", "9").Result;

            Console.WriteLine(response.Content.ReadAsStringAsync().Result);
        }

// Controller and Action in Web API

public class SupplierController : ApiController
   {
    NorthwindEntities context = new NorthwindEntities();

    [HttpPost]
    public HttpResponseMessage RemoveCategory(string CategoryID)
    {
    try
    {
    int CatId= Convert.ToInt32(CategoryID);
    var category = context.Categories.Where(c => c.CategoryID == CatId).FirstOrDefault();
    if (category != null)
    {
    context.Categories.DeleteObject(category);
    context.SaveChanges();
    return Request.CreateResponse(HttpStatusCode.OK, "Delete successfully CategoryID = "     +     CategoryID);
    }
    else
    {
    return Request.CreateResponse(HttpStatusCode.InternalServerError, "Invalid     CategoryID");
    }
    }
    catch (Exception _Exception)
    {
    return Request.CreateResponse(HttpStatusCode.InternalServerError, _Exception.Message);
    }
    }

When I Post custome object that represent “Category” table in Northwind database all things working properly but I am not able to post scalar data like Integer and String

When I am post string data type I am getting following exception

{“Message”:”No HTTP resource was found that matches the request URI ‘http://localhost:49931/api/Supplier/RemoveCategory/‘.”,”MessageDetail”:”No action was found on the controller ‘Supplier’ that matches the request.”}

Can anyone guide me?

  • 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-12T08:36:29+00:00Added an answer on June 12, 2026 at 8:36 am

    You will have to mark your CategoryID parameter as [FromBody]:

    [HttpPost]
    public HttpResponseMessage RemoveCategory([FromBody] string CategoryID)
    { ... }
    

    By default, simple types such as string will be model bound from the URI.

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

Sidebar

Related Questions

I've a ASP.Net application which utilizes SQL Server Stored Procedures and Web Services using
I am using ASP .Net 3.5 and trying to invoke a WebService using javascript
I have already built my web pages using jQueryMobile and ASP.NET MVC framework. Now,
I am trying to work with COM+ using c# and ASP.NET. I have been
I am trying to implement a reoccurring timer function asp.net. I am not able
I am using Telerik ASP.Net Ajax controls (theoretically shouldn't matter who makes the 3rd
I have an ASP .NET Web Forms application that makes use of the 'WebMethod'
I am not actually using the Razor from ASP.NET MVC, I am using the
I want to send some values from my iPhone application to an ASp.Net web
I have an irritating problem, I'm creating an asp.net web service; this service should

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.