Closed kimdre closed 1 year ago
@kimdre I think this is due to the order and similarity of your urls. The /contacts
endpoint is getting interpreted as /{user_id}/contacts
, with an empty user_id
. ( @vitalik I assume this is a problem with django's routing, rather than anything ninja is doing? )
This should be pretty easily fixed by moving the get_account_contacts_of_current_user
endpoint above get_account_contacts
, and/or by changing the url for get_account_contacts
to "/{user_id:int}/contacts"
Thank you 👍 Both your proposals did work for me.
I have similar problem. I don't understand why different endpoint is considered a different one... Why would something like that happen?
I am using ninja with authentication and now want to retrieve objects of the authenticated user. I get an error that I'm not able to fix. The api wants me to pass a valid user_id, however I already to that (I confirmed it returns the correct value and this also works in other functions)
What am I missing here or what can I do to fix this?
Request URL:
http://127.0.0.1:8000/api/accounts/contacts?limit=100&offset=0
422 Error: Unprocessable Entity
Response bodyMy api.py The first 2 functions work (one with id of authenticated user and one with passed id in the url). The third one does not work
My schema.py:
My models.py