0
我正在使用文档数据库,并且一些文档可能会变得非常大以至于超过了大小限制(2MB)。我想存储大块作为附件,这是我的代码片段:在DocumentDB中创建附件时无效的请求有效负载错误
var stringifiedItems = JsonConvert.SerializeObject(doc.Items);
var attachmentStream = new MemoryStream(Encoding.UTF8.GetBytes(stringifiedItems));
doc.Attachment = await _client.CreateAttachmentAsync(GetDocumentLink(docId), attachmentStream, new MediaOptions()
{
ContentType = "application/json",
Slug = "Items.json"
});
但CreateAttachmentAsync()调用总是抛出一个一般性的错误:
"The request payload is invalid. Ensure to provide a valid request payload."
有人可以揭示光我错过了我的代码,或给出如何排除故障的建议?
非常感谢你!这解决了我的问题。 – Jiaye
@Jayaye如果帖子有助于解决问题,您可以将其作为回答接受,以便其他具有相同问题的社区可以轻松识别答案。 –