Insert data to my collections via Powershell with curl (api https)

Hi, if possible add data or insert a new document via powershell with curl

curl -X POST
https://db.fauna.com/query/1
-H ‘Authorization: Bearer $FAUNA_SECRET’
-H ‘Content-Type: application/json’
-d ‘{“query”: " q.Create(q.Collection(‘Foos’), q.Var(‘data’))"}’

Or:
$Form = @{
firstName = ‘Bruce’
lastName = ‘Wayne’
email = ‘batman@wayne.com’
occupation = ‘Superhero’
}
$Result = Invoke-WebRequest -Uri [sample-url] -Method Post -Form $Form

Sure! All communication with Fauna is done over HTTP. The drivers provide a lot of quality of life over raw HTTP, and the dashboard uses the Javascript driver, but otherwise it all comes down to the HTTP requests.

We document the API here: POST - Fauna Docs

I can see that you are using the correct endpoint for making FQL v10 requests, but you are trying to use FQL v4 syntax[1]. You will need to make sure you use v10 syntax instead.

v10 queries are string-based, so you can provide a JSON body like

{
  "query": "Foos.create({ field1: 1, field2: 2 })"
}

[1] Please also note that preceding FQL v4 methods with q. is just a convention that has been used with the v4 javascript driver, and not actually part of the FQL v4 language. v4 queries have to be compiled into a separate wire protocol, which we don’t document.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.