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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:28:56+00:00 2026-05-15T16:28:56+00:00

Having trouble getting my JQuery POST to be accepted by the WCF Service. Here’s

  • 0

Having trouble getting my JQuery POST to be accepted by the WCF Service. Here’s the POST from the javascript:

function jqueryPost() {
    var url = "/LoggingTest";
    $.post(url, { message: "test message" });
}

This is how I’m accepting the POST, via an Interface:

[OperationContract]
[WebInvoke(Method = "POST",
           UriTemplate = "/LoggingTest",
           BodyStyle = WebMessageBodyStyle.Bare)]
void LoggingTest(string message);

And the implementation:

public void LoggingTest(string message)
{
    log.Debug(message, null);
}

When I call the function jqueryPost I see in the web inspector an HTTP response of 400 Bad Request. Not sure how to get the POST request to work.

(Added on 7/1)
@James, here is the output from the web inspector:

http://localhost:4252/LoggingTest
HTTP Information
Request Method:POST
Status Code:400 Bad Request
Request Headers
Accept:/
Cache-Control:max-age=0
Content-Type:application/x-www-form-urlencoded
Origin:http://localhost:4252
Referer:http://localhost:4252/
User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; C -) AppleWebKit/532.4 (KHTML, like Gecko) Qt/4.6.2 Safari/532.4
X-Requested-With:XMLHttpRequest
Form Data
message:test message
Response Headers
Content-Length:1165
Content-Type:text/html
Date:Thu, 01 Jul 2010 18:56:15 GMT
Server:Microsoft-HTTPAPI/1.0

  • 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-05-15T16:28:57+00:00Added an answer on May 15, 2026 at 4:28 pm

    So, I just ended up doing this, Interface:

    [OperationContract]
    [WebInvoke(Method = "POST",
               UriTemplate = "LoggingTest/{logID}/{logLevel}?errorCode={errorCodeInt}",
               BodyStyle = WebMessageBodyStyle.Bare)]
    void LoggingTest(string logID, string logLevel, int errorCodeInt, Stream message);
    

    Implementation:

    public void LoggingTest(string logID, string logLevel, int errorCodeInt, Stream message)
        {
            switch (logLevel)
            {
                case "error":
                    log.Error(errorCodeInt, message, null);
                    break;
                case "warn":
                    log.Warn(errorCodeInt, message, null);
                    break;
                case "info":
                    log.Info(errorCodeInt, message, null);
                    break;
                case "debug":
                    log.Debug(errorCodeInt, message, null);
                    break;
            }
        }
    

    And now it works. Must have something to do with the parameters being passed in the UriTemplate, because when I changed it to pass the parameters like so:

    UriTemplate = "LoggingTest/{logID}/{logLevel}?errorCode={errorCodeInt}",
    

    it started accepting the POST.

    Edit 7/7: Here’s the final JavaScript also:

    jqueryPost('LoggingTest/LogID/debug?errorCode=0', { message: 'this is a test message'} ;
    
    function jqueryPost(url, message) {
        $.post(url, message);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble getting the following JQuery script to function properly - its functionality
I'm having trouble getting my callback function to work in post: I've got this
I'm having trouble getting a response back from a Jquery ajax call... (It's a
I am having trouble getting inside my Search WebMethod from my JQuery call. Maybe
I'm having some trouble getting jquery to post some json data to a rest
I'm having some trouble getting jQuery to play nice with DokuWiki - has anyone
Getting started with jquery and having trouble getting hello world type example going for
I'm having trouble getting JQuery to load in IE7, works fine in all other
I'm having trouble getting jQuery to allow only one content-DIV to be visible at
I'm having trouble getting some text to pulsate using the jquery UI plugin in

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.