Skip to content

Unable to create database document #20

Description

@doricci

First of all, thank you for your awesome work!!

I currently tring to create a set of service for Angular that will communicate with the REST API of Appwrite.

When I'm trying to create a new document in a collection from the database, I got a PHP error:

Warning: Illegal string offset '$permissions' in /usr/share/nginx/html/app/controllers/database.php on line 388

Notice: Array to string conversion in /usr/share/nginx/html/app/controllers/database.php on line 388

Fatal error: Uncaught TypeError: Argument 1 passed to Database\Database::createDocument() must be of the type array, string given, 
called in /usr/share/nginx/html/app/controllers/database.php on line 430 and defined in /usr/share/nginx/html/src/Database/Database.php:184 Stack trace: 
#0 /usr/share/nginx/html/app/controllers/database.php(430): Database\Database->createDocument('A"test":"test"}') 
#1 [internal function]: {closure}('5d7e5234e6d9d', 'A"test":"test"}', Array, Array, '', '', 'assign') 
#2 /usr/share/nginx/html/vendor/utopia-php/framework/src/App.php(401): call_user_func_array(Object(Closure), Array) 
#3 /usr/share/nginx/html/app/app.php(792): Utopia\App->run(Object(Utopia\Request), Object(Utopia\Response)) 
#4 /usr/share/nginx/html/public/index.php(27): include('/usr/share/ngin...') 
#5 {main} thrown in /usr/share/nginx/html/src/Database/Database.php on line 18

This error appear if I'm using a REST client or if I call the backend from my service.

This is my request :

  • Method: POST
  • path: /v1/database/{collectionId}/documents
  • headers :
{
  "content-type": "application/json",
  "x-appwrite-key":"API_KEY",
  "x-appwrite-project":"PROJECT_ID"
 }
  • body:
{
  "data":"{\"test\":\"test\"}",
  "read":[],
  "write":[],
  "parentDocument":"",
  "parentProperty":"",
  "parentPropertyType":"assign"
}

Is it me that is missing something from the documentation about the structure of the data to send or is this really a bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions