I am trying to execute the following command in powershell:
curl "https://generativelanguage.googleapis.com/v1beta3/models/text-bison-001:generateText?key=AIzaSyAxHrnH91lSLOeaWs5Rda1_PTn-OnWN9Kg" -H 'Content-Type: application/json' -X POST -d '{ "prompt": { "text": "Write a story about a magic backpack"} }'
but receiving the following error:
"System.String" to type "System.Collections.IDictionary".
At line:1 char:140
+ ... SLOeaWs5Rda1_PTn-OnWN9Kg" -H 'Content-Type: application/json' -X POST ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I tried the following command as some of them said to.
Get-Command curl
----------- ---- ------- ------
Alias curl -> Invoke-WebRequest
but Invoke-WebRequest also did not helped.
From this:
It looks like PowerShell's
curl
doesn't support the same args as Linux'scurl
.I would either switch to WSL to use real
curl
, or use native PowerShell like so: