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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:46:57+00:00 2026-06-10T01:46:57+00:00

I have a new method in web api [HttpPost] public ApiResponse PushMessage( [FromUri] string

  • 0

I have a new method in web api

[HttpPost]
public ApiResponse PushMessage( [FromUri] string x, [FromUri] string y, [FromBody] Request Request)

where request class is like

public class Request
{
    public string Message { get; set; }
    public bool TestingMode { get; set; }
}

I’m making a query to localhost/Pusher/PushMessage?x=foo&y=bar with PostBody:

{ Message: "foobar" , TestingMode:true }

Am i missing something?

  • 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-10T01:46:59+00:00Added an answer on June 10, 2026 at 1:46 am

    A post body is typically a URI string like this:

    Message=foobar&TestingMode=true
    

    You have to make sure that the HTTP header contains

    Content-Type: application/x-www-form-urlencoded
    

    EDIT: Because it’s still not working, I created a full example myself.
    It prints the correct data.
    I also used .NET 4.5 RC.

    // server-side
    public class ValuesController : ApiController {
        [HttpPost]
        public string PushMessage([FromUri] string x, [FromUri] string y, [FromBody] Person p) {
            return p.ToString();
        }
    }
    
    public class Person {
        public string Name { get; set; }
        public int Age { get; set; }
    
        public override string ToString() {
            return this.Name + ": " + this.Age;
        }
    }
    
    // client-side
    public class Program {
        private static readonly string URL = "http://localhost:6299/api/values/PushMessage?x=asd&y=qwe";
    
        public static void Main(string[] args) {
            NameValueCollection data = new NameValueCollection();
            data.Add("Name", "Johannes");
            data.Add("Age", "24");
    
            WebClient client = new WebClient();
            client.UploadValuesCompleted += UploadValuesCompleted;
            client.Headers["Content-Type"] = "application/x-www-form-urlencoded";
            Task t = client.UploadValuesTaskAsync(new Uri(URL), "POST", data);
            t.Wait();
        }
    
        private static void UploadValuesCompleted(object sender, UploadValuesCompletedEventArgs e) {
            Console.WriteLine(Encoding.ASCII.GetString(e.Result));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have new problem. My code: .method public static void Main() cil managed {
I have created a gem that adds a new method to the class ActiveRecord::Base.
Consider an ASP.NET Web API service that redirects public class ThisController : ApiController {
I have an ASP.NET MVC 4 application which uses the new ASP.NET Web API.
I've created a method using the new WebAPI features in MVC4 and have it
I have a __new__ method as follows: class MyClass(object): def __new__(cls, *args): new_args =
I have created a new method in one of the project's controllers that it
I have a variable @products = Product.all defined inside new method in a controller.
I have an application (ASP.NET MVC) that uses a Next New method to get
I have a doubt about orkut's new URL Writing method. Earlier the home page

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.