cs0815
cs0815

Reputation: 17418

bad request error when persisting TableEntity

I have a TableEntity like this:

public class TableEntity : TableEntity
{
    public string SomeXml { get; set; }
}

which contains an XML string called SomeXmL. Most TableEntities persist fine but for some I get:

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

The XML string of one of the TableEntities producing the exception contains 33933 characters. Is there a limit? Not sure how else to establish the cause of the exception. One sample XML causing the exception can be found here.

Upvotes: 1

Views: 785

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136369

The reason you're getting this error is because that data you're trying to insert is exceeding the maximum size allowed for an entity attribute. The maximum size of an entity attribute is 64KB however because strings in Azure Tables are UTF-16 encoded, maximum size of a String type attribute is 32KB.

Because your XML size is more than 32KB, you're getting this error.

When I tried to insert the sample data you shared in a table in my storage account I got the following error back:

{
    "odata.error": {
        "code": "PropertyValueTooLarge",
        "message": {
            "lang": "en-US", 
            "value": "The property value exceeds the maximum allowed size (64KB). If the property value is a string, it is UTF-16 encoded and the maximum number of characters should be 32K or less.\nRequestId:693f46ec-0002-0012-3a5a-cbcb16000000\nTime:2016-06-21T01:14:00.4544620Z"
            }
        }
    }

Upvotes: 4

Related Questions