Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
HI,

I have created a wcf service api which return json format. But when i call this api in simple html page and when i click on submit button then api show "HTTP/1.1 400 Bad Request" Error.

ApI show The server encountered an error processing the request. See server logs for more details.

My Serivce Interface like this

C#
[ServiceContract]
   public interface IImageProcessing
   {
       [OperationContract]
       [WebInvoke(Method = "POST", UriTemplate = "/SaveSKU", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
       ImageResponse SaveSKU(string sku);
   }


In .SVC Files i write a code

C#
ImageResponse _imageResponse;
public ImageResponse SaveSKU(string sku)
{
    _imageResponse=new ImageResponse();
    _imageResponse.Result=true;
    return _imageResponse;
}


This service when i call in dot.net it working but when i call in html page is give error.

My HTML Page Simple calling API
HTML
<form accept="application/json"  action="http://localhost:61132/ImageProcessing.svc/SaveSKU" method="post">
    <input type="text" id="sku" name="sku" />
    <input type="text" id="message" name="message" />
    <input type="text" id="status" name="status" />
    <input type="submit" value="submit" id="btnsubmit" />
</form>

When i calling my service in html page it give HTTP/1.1 400 Bad Request I have checked using fiddler.

Please help me about this problem What I am missing to call in my WCF Service

Thanks in advance
Posted
Updated 30-Apr-13 21:20pm
v3
Comments
Bernhard Hiller 29-Apr-13 9:23am    
"See server logs for more details." in BOLD face. And did you do so? What's in the server logs?
Ram Kumar(Webunitech) 29-Apr-13 9:48am    
Server log does not show any thing and where i found the server log i just see the event view log . Please tell me where i see the server log

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900