Getting "One of the specified inputs is invalid" in Azure CosmosDb PatchItemAsync

chi*_*Dev 5 azure-cosmosdb azure-cosmosdb-sqlapi

Below is the code that I have:

List<PatchOperation> patchOperations = new List<PatchOperation>();
            patchOperations.Add(PatchOperation.Replace("/endpointId", 100));
string id = "id1";
PartitionKey partitionKey = new PartitionKey("partitionkey1");

await _container.PatchItemAsync<Watermark>(id,
    partitionKey,
    patchOperations);
Run Code Online (Sandbox Code Playgroud)

I am expecting to get endpointId property to be replaced with 100.

但是,我面临着 Message: {"Errors":["One of the specified inputs is invalid"]}

我可以检查一下我缺少哪一部分吗?或者我是否必须等待为我的 Cosmos 数据库启用补丁私人预览功能?

Ian*_*cer 9

One of the specified inputs is invalid对于登陆此处寻找 Cosmos 可能响应其他请求类型的原因的其他人,您可能需要将您的Id属性重命名为id小写或添加属性:

[JsonProperty("id")]
public string Id { get; set; }
Run Code Online (Sandbox Code Playgroud)


Saj*_*ran 0

即使错误表明"One of the specified inputs is invalid"您应该看到状态代码 400,它表示Bad Request. 因此,您的帐户需要启用私人预览功能。

EnablePreview您还可以通过在启动模拟器时添加以下内容来启用模拟器的补丁:

.\CosmosDB.Emulator.exe /EnablePreview
Run Code Online (Sandbox Code Playgroud)

为了启用它,您可以使用此表格进行注册,该过程应该在 15-20 分钟内完成。如果这不起作用请告诉我