Diagnose and troubleshoot bad request exceptions in Azure Cosmos DB
APPLIES TO: NoSQL
The HTTP status code 400 represents the request contains invalid data or it's missing required parameters.
Missing the ID property
On this scenario, it's common to see the error:
The input content is invalid because the required properties - 'id; ' - are missing
A response with this error means the JSON document that is being sent to the service is lacking the required ID property.
Solution
Specify an id
property with a string value as per the REST specification as part of your document, the SDKs do not autogenerate values for this property.
Invalid partition key type
On this scenario, it's common to see errors like:
Partition key ... is invalid.
A response with this error means the partition key value is of an invalid type.
Solution
The value of the partition key should be a string or a number, make sure the value is of the expected types.
Wrong partition key value
On this scenario, it's common to see these errors:
Response status code does not indicate success: BadRequest (400); Substatus: 1001
PartitionKey extracted from document doesn�t match the one specified in the header
A response with this error means you are executing an operation and passing a partition key value that does not match the document's body value for the expected property. If the collection's partition key path is /myPartitionKey
, the document has a property called myPartitionKey
with a value that does not match what was provided as partition key value when calling the SDK method.
Solution
Send the partition key value parameter that matches the document property value.
Numeric partition key value precision loss
On this scenario, it's common to see errors like:
The requested partition key is out of key range, possibly because of loss of precision of partition key value
A response with this error is likely to be caused by an operation on a document with a numeric partition key whose value is outside what is supported by Azure Cosmos DB. See Per-item limits for the maximum length of numeric property value.
Solution
Consider using type string
for partition key if requiring precise numeric values.
Next steps
- Diagnose and troubleshoot issues when you use the Azure Cosmos DB .NET SDK.
- Learn about performance guidelines for .NET v3 and .NET v2.
- Diagnose and troubleshoot issues when you use the Azure Cosmos DB Java v4 SDK.
- Learn about performance guidelines for Java v4 SDK.