Restful WCF service POST methods returns HTTP400 error in fiddler2

have created simple Restful service for log in verification. Following are my interface and class definitions.

Interface IDemo:

public interface IDemo
    [WebInvoke(RequestFormat = WebMessageFormat.Json,
               ResponseFormat = WebMessageFormat.Json,
               BodyStyle = WebMessageBodyStyle.Bare,
               UriTemplate = "/ValidateUser?Username={UserName}&Password={Password}",
               Method = "POST")]
    string  ValidateUser(string Username, string Password);

Class Demo :

public class Demo:IDemo
    public string ValidateUser(string Username, string Password)
        Users objUser = new Users();
        objUser.UserID = Username;
        objUser.Password = Password;
        string Msg = LoginDataService.ValidateUser(Username, Password);
        return Msg;

localhost:49922/Demo.svc/ValidateUser?Username=demo&Password=demo (with http:\)

When I try to parse the above URL under the Post Method in Fiddler2 I got Bad Request HTTP400 error.

Can anyone help me what is wrong in my code.

Thanks & Regards,



Your URI template looks like you are sending the parameters in the URL. But when you use POST the parameters are sent in the http body.

Note you should not send the username and passord in the url as it can be logged.

For the above REST method the POST from Fiddler needs to be as shown below:

POST http://localhost/Sample/Sample.svc/ValidateUser?Username=demo&Password=demo HTTP/1.1
User-Agent: Fiddler
Content-Type: application/json
Host: rajeshwin7
Content-Length: 0

Doing so i get back a 200 OK HTTP Status as shown below:

HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 44
Content-Type: application/json; charset=utf-8
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 14 Jun 2012 15:35:28 GMT

"Server returns username demo with password demo"

Need Your Help

2 Table Views on One Page - Two NSArrays

iphone objective-c xcode

Hello I am brand new to xCode and iPhone development. I have two different TableView controls on one page. I have NSArray #1 that needs to be the datasource of TableView #1 and NSArray #2 that ne...