I am trying to insert data into Azure DocumentDb, however I am getting the following error
The input name "123456" is invalid. Ensure to provide a unique non-empty string less than '255' characters.","The request payload is invalid. Ensure to provide a valid request payload."]}
I am using the following code:
using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(myString)))
{
await client.CreateDocumentAsync(documentCollection.DocumentsLink, Document.LoadFrom<Document>(ms));
}
This code appears to be correct, however I have also tried using the docomentCollection.SelfLink and that also fails.
The database and collection have been created and I can verify this through the azure portal, however no data is ever inserted.
DocumentDB treats id
as a special property, in which it must be a unique non-empty string with less than 255 characters.
In this case, I believe you are creating a document with the id
as a numeric value:
{
"id": 123456
}
You will need to cast the id
to a string:
{
"id": "123456"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With