Rest APi metthod not allowed 405 Error


I was trying to implement simple api request using user application documentation

from trytond.application import app

@app.route('/hello', methods=['GET'])
def hello(request):
    return 'Hello world'

i generated authentication token from user application tab and tried to send it on header but no luck

I hope i am sending in right format

Is the file where the route is declared imported in the of the module?

Thank’s a lot for replying . actually i am new to trytond… i just setup using docker on windows pc . thing is i cant find the project directory in the container . i tried directly implementing the code in docker using ssh

Regards Saif

You can take a look to the Dockerfile for Tryton in order to understand how and where Tryton is deployed

1 Like

thanks a lot i was able to find the Project Directory

@ced i tried importing that file in but still same issue persist

The header should be Authorization with: bearer <key>.

Hey @ced

Thanks for your help i tried importing file in


    import os
    import time
    import warnings
    from email import charset
    from test import *

    __version__ = "5.6.4"

    os.environ['TZ'] = 'UTC'
    if hasattr(time, 'tzset'):

    if time.tzname[0] != 'UTC':
        warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])

    # set email encoding for utf-8 to 'quoted-printable'
    charset.add_charset('utf-8', charset.QP, charset.QP)

and my

    from trytond.application import app

    @app.route('/hello', methods=['GET'])
    def hello(request):
        return 'Hello world'

but not sure where it did go wrong. i restarted the container after importing but no luck

When I talked about the file, I was not talking about the trytond/ file but the of your custom module.

thanks @ced
i was able to get it working by implementing same code in of timesheet module .although i was not required to send bearer token … i got the response directly without any user authorization

Thanks a lot is there a way i could log the error using console in docker

It is needed only if the route is decorated with user_application.