Microsoft.Azure.Documents.DocumentClientException -Exception HTTP错误400。请求标头的大小太长

时间:2019-06-05 19:30:21

标签: azure azure-cosmosdb

Microsoft.Azure.Documents.DocumentClientException-异常HTTP错误400。请求标头的大小太长。

库:Microsoft.Azure.DocumentDB.Core SDK 2.4.0 方法:CreateDocumentQuery-

从SDK中获取异常

Exception Message- One or more errors occurred. (<!DOCTYPE HTML PUBLIC 
"-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"> 
</HEAD>
<BODY><h2>Bad Request - Request Too Long</h2>
<hr><p>HTTP Error 400. The size of the request headers is too long.</p>
</BODY></HTML>
, Request URI: /dbs/sssss==/colls/sssss=/docs, RequestStats: , SDK: 
Windows/10.0.14393 documentdb-netcore-sdk/2.4.0) -Inner Exception Message- 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"> 
</HEAD>
<BODY><h2>Bad Request - Request Too Long</h2>
<hr><p>HTTP Error 400. The size of the request headers is too long.</p>   
</BODY></HTML>
, Request URI: /dbs/ssssss==/colls/ssssss=/docs, RequestStats: , SDK: 
Windows/10.0.14393 documentdb-netcore-sdk/2.4.0

异常并非一直存在。间歇性地

1 个答案:

答案 0 :(得分:0)

在Feed选项中添加以下选项,它将解决

          var queryResult = _documentClient.CreateDocumentQuery
                    (_documentCollection.SelfLink,
                     new SqlQuerySpec()
                     {
                         QueryText = Convert.ToString(sqlQuery),
                         Parameters = sqlParameterCollection
                     },
                     new FeedOptions()
                     {
                         EnableCrossPartitionQuery = true,
                         MaxItemCount = 1,
                         ResponseContinuationTokenLimitInKb = 1,

                     }).AsDocumentQuery();