I know that there are several posts asking about 400 error, and I believe that I have read all of them, but I think that the problem I am facing is different.
This is my WCF service contract.
[WebInvoke(UriTemplate = "/cust_key/{key}/prod_id/{id}", Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)] Stream GetData(string key, string id, string data);
And this is the code that I use to send a request for my vacation svc
request.RequestUri = new Uri("http://localhost:3138/v1/cust_key/company1/prod_id/testProductID"); request.ContentType = "application/xml"; request.HttpMethod = "POST"; string xml = @"<Product><name>dell 400</name><price>400 dollars</price></Product>"; byte[] message = Encoding.ASCII.GetBytes(xml); string data = Convert.ToBase64String(message); response = request.MakeWebRequest(null, data);
This gave me 400 errors with an error. I tried changing the xml line to the next two and they also produce 400 errors
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"> <![CDATA[<Product><name>dell 400</name><price>400 dollars</price></Product>]]> </string>
or
<![CDATA[<Product><name>dell 400</name><price>400 dollars</price></Product>]]>
If the xml payload is an empty string, then everything is fine and 200 is returned. Can someone give me a hand?
Edit: section of my web.config. he goes out of the box from the WCF REST Service Template 40 (CS)
<system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <standardEndpoints> <webHttpEndpoint> <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> </webHttpEndpoint> </standardEndpoints>
Laguna
source share