-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to create database document #20
Comments
@doricci, first of all seems like it is a bug, because the server is printing an uncaught error - I will make sure to fix it by the next release. Regarding this specific issue, you should pass the data param as a JSON object and not a string. Make sure you have created a collection with matching structure to be able to pass the document creation validation. If you have problems creating a new collection, we have a previous issue open about some parts missing in the docs. In the meantime we have a collection structure example here: #19 |
I might also be able to check if data parameter is a string and try to parse as a JSON to try an avoid this kind of an obvious confusion. |
@eldadfux thx for the quick answer! I'm sending the data as a json object {
"data": {"test":"test"},
"read": [],
"write": [],
"parentDocument": "",
"parentProperty": "",
"parentPropertyType": "assign"
} and I get the current error now: {
"message":"Bad structure. Invalid document (#): Missing collection attribute $collection",
"code":400,
"file":"\/usr\/share\/nginx\/html\/app\/controllers\/database.php",
"line":434,
"trace":[
{
"function":"{closure}",
"args":[
"5d7e5234e6d9d",
{
"test":"test",
"$permissions":{
"read":[
"*"
],
"write":[
"*"
]
}
},
[
"*"
],
[
"*"
],
"",
"",
"assign"
]
},
{
"file":"\/usr\/share\/nginx\/html\/vendor\/utopia-php\/framework\/src\/App.php",
"line":401,
"function":"call_user_func_array",
"args":[
{
},
{
"collectionId":"5d7e5234e6d9d",
"data":{
"test":"test"
},
"read":[
"*"
],
"write":[
"*"
],
"parentDocument":"",
"parentProperty":"",
"parentPropertyType":"assign"
}
]
},
{
"file":"\/usr\/share\/nginx\/html\/app\/app.php",
"line":792,
"function":"run",
"class":"Utopia\\App",
"type":"->",
"args":[
{
},
{
}
]
},
{
"file":"\/usr\/share\/nginx\/html\/public\/index.php",
"line":27,
"args":[
"\/usr\/share\/nginx\/html\/app\/app.php"
],
"function":"include"
}
],
"version":"latest"
} |
For all the call about the collection, I have no issues, I find that the REST Client and the JS SDK are clear and doesn't need a lot of knowledge to be understood |
Umm, this is another thing that should be fixed by next version. To fix it now just add '$collection' key to your data parameter JSON: {
"$collection": "YOUR_COLLECTION_ID_SAME_AS_IN_PATH",
"data": {"test":"test"},
"read": [],
"write": [],
"parentDocument": "",
"parentProperty": "",
"parentPropertyType": "assign"
} |
@doricci feel free to join us on gitter as well. |
Committed a fix for the missing collection issue: |
Thank you, now I'm able to add a document to the collection with the fix that you suggested, but the $collection has to be in the data object that is send. I waiting the next release to remove this fix from my code! I missed the documentation about the creation of the collection that you mentionned in #19 . But thank you again for the quick answer and the great work!! |
Happy to help, I am already working on the fix, should be a one liner quick fix and probably be shipped in next version (might be out this week!). |
Hey, thanks for your time, now I'm able to login and register a new user without the api key, my issue was with angular, the session cookie wasn't set after the login .... But now that I'm logged, the user is unable to create or read new collections. Did I miss something in the documentation about how to create a collection? Or do I need to update the current user to add some permission? |
@doricci As mentioned before, this is a section of the documentation that is lacking and I am working on improving it + providing some real world examples. Currently, Appwrite only allows creation of new collection using a Server SDK + API key + Relevant Scope ('collections.write'). This is meant to avoid users from abusing your collection creation endpoint. If you want to allow all users to create new documents in a collection you created using a server SDK just create it with a public ("*") read permission. |
@doricci another thing I forgot to mention, in coming version we will add support for creating collections directly from the dashboard, which will make this process easier when getting started. |
Ok thanks! |
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:
This error appear if I'm using a REST client or if I call the backend from my service.
This is my request :
Is it me that is missing something from the documentation about the structure of the data to send or is this really a bug?
The text was updated successfully, but these errors were encountered: