Dimitri
Dimitri

Reputation: 2858

WCF Post Operation Contract returning 400 bad request

So basically I have an wcf service which should handle POST method an posted data is a url encoded form. this are my appropriate classes

[ServiceContract]
    public interface IMyService
    {
        [OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare)]  
        Stream Check(RequestObject request);
    }
}

public class MyService : IMyService
{
    public Stream Check(RequestObject request)
    {
        // do some stuff;
        return null; // for brevity
    }
}

[DataContract]
    public class RequestObject
    {
        [DataMember(Name = "KEY")]
        public string Key { get; set; }
    }

every time I make a post request to the url with request body being KEY=1234 (or anything) the service returs 400 Bad Request. I tried making the service method parameterless and than it work. I mean it return 200 OK. am I doing something wrong here ? if needed I can provide the web.config

Upvotes: 0

Views: 688

Answers (1)

It seems Service doesn't like your data format. Try to send xml or json.

You can check here to see format type handling.

Upvotes: 1

Related Questions