CosmosDB icon indicating copy to clipboard operation
CosmosDB copied to clipboard

New-CosmosDbDocument - PowerShell is returning error "Cannot convert 'System.Collections.ArrayList' to the type 'System.String' required by parameter 'Message'. Specified method is not supported."

Open takis-kapas opened this issue 2 years ago • 0 comments

Issue

I am getting the CosmosDB noSQL context using a Service Principal that has the "Contributor" role in the CosmosDB account. I am building a JSON document, based on your instruction in the "New-CosmosDbDocument" module When I am trying to execute the command "New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $collectionName -DocumentBody $document" I am getting the following error from PowerShell:

$document = @" { "id": "$([Guid]::NewGuid().ToString())", "content": "Some string", "more": "Some other string" } "@

New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $collectionName -DocumentBody $document

Write-Error : Cannot convert 'System.Collections.ArrayList' to the type 'System.String' required by parameter 'Message'. Specified method is not supported. At line:4 char:17 Write-Error $Error CategoryInfo : InvalidArgument: (:) [Write-Error], ParameterBindingException FullyQualifiedErrorId : CannotConvertArgument,Microsoft.PowerShell.Commands.WriteErrorCommand

System Information

  • PS Version: 5.1.19041.2364
  • Client: PowerShell ISE, VS Code
  • OS: Windows 10
  • Module Version: CosmosDB 4.7.0

takis-kapas avatar Feb 09 '23 15:02 takis-kapas