So I am trying to run a query with the firebase rest api using Godot
to give you an idea this is the way that I make an update for a document:
func update_document(http: HTTPRequest) -> void:
var fields = {}
fields.Name = {"stringValue": "Martin"}
var document := { "fields": fields }
var body := to_json(document)
var url := "https://firestore.googleapis.com/v1/projects/my_project_id/databases/(default)/documents/Users"
http.request(url, _get_request_headers(), false, HTTPClient.METHOD_PATCH, body)
Now Iam trying to make a query that return the 100 best scores, I am trying ,first, running a simple query but is not Working, it´s returning error 400:
func query_document(http: HTTPRequest) -> void:
var fields = {
"structuredQuery": {
"from": [{
"collectionId": "Users"
}],
"where": {
"fieldFilter": {
"field": {
"fieldPath": "total"
},
"op": "EQUAL",
"value": {
"intetgerValue": "10",
}
}
}
}
}
var document := { "fields": fields }
var body := to_json(document)
var url := "https://firestore.googleapis.com/v1beta1/projects/myproject_id/databases/(default)/documents:runQuery"
http.request(url, _get_request_headers(), false, HTTPClient.METHOD_POST,body)