
I cannot use the SDK and I'm trying to call via PHP to get the value of the paramaters of a document but I don't find the right documentation for this and an error appears:
This is my code:
<?php header('Content-Type: application/json'); ini_set('display_errors', 1); // Configuración de Appwrite extraída de config.js $DATABASE_ID = 'xxx'; $COLLECTION_ID = 'xxx'; $PROJECT_ID = 'xxx'; $ENDPOINT = 'https://cloud.appwrite.io/v1'; $API_KEY = 'xxx'; $userId = 'xxx'; $endpoint = "https://cloud.appwrite.io/v1/databases/$DATABASE_ID/collections/$COLLECTION_ID/documents"; $query = 'equal("userId","' . $userId . '")'; // IMPORTANTE: agregar queries[] como múltiples parámetros si hace falta más de uno $url = $endpoint . '?queries[]=' . urlencode($query); $headers = [ "Content-Type: application/json", "X-Appwrite-Project: $PROJECT_ID", "X-Appwrite-Key: $API_KEY" ]; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_CUSTOMREQUEST => "GET", ]); $response = curl_exec($curl); if (curl_errno($curl)) { echo 'Error de cURL: ' . curl_error($curl); } else { $data = json_decode($response, true); echo json_encode($data, JSON_PRETTY_PRINT); } curl_close($curl); And this is the response I receive: { "message": "Invalid query: Syntax error", "code": 400, "type": "general_query_invalid", "version": "1.6.2" } Could you help me to find the right way to ask to documents?TL;DR
Developers are attempting to retrieve document parameters through curl in PHP but encounter a syntax error. The issue lies in the query formatting. The correct way to structure the query is by encoding it and adding it as a multiple parameter. This solution should resolve the error and allow successful retrieval of the document parameters.Recommended threads
- 404 page not found
Hi, I'm trying to run Appwrite on a different port (e.g., 7777) because I already use Apache to handle domain-based redirection using ProxyPass. For example, I ...
- oauth logging in, person already exists
Dear all, I recently encountered an issue with Oauth. For creating new users, it works fine. However, when logging in to an existing user (I had already previ...
- I got 401 wrong
