Saturday, September 22, 2012

(400) Bad Request with WCF Data Services


The remote server returned an error: (400) Bad Request.

Getting this error when you call the SaveChanges() of your Entity context through your WCF Data Service?

The remote server returned an error: (400) Bad Request.

InnerException is null. Response object's Statuscode: System.Net.HttpStatusCode.BadRequest

No further information available in exception object.

 

Some context on the exception:

I faced this error because of the insufficient request size in my service config file. After a log of debugging and trail and error, I found that the huge xml contained is one of the entities is actually causing the issue. Further found that the SaveChanges succeeds when the xml size is small.Thus able to determine the issue was with request size

 

Resolution:

Increase the request size in the config file of the project where your data service recides and this should resolve the issue

<binding name="DataServiceBinding" ..... maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" .......>

1 comment:

  1. Thanks! This happened to me recently, your blog post helped a *lot*.

    ReplyDelete