# Rest APi metthod not allowed 405 Error

**URL:** <https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058>\
**Category:** Developer\
**Created:** [July 23, 2020, 1:11pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058 "2020-07-23T13:11:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)\
**Post date:** [July 23, 2020, 1:11pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/1 "2020-07-23T13:11:18Z")

</div>

Hey

I was trying to implement simple api request using [user application](https://docs.tryton.org/projects/server/en/latest/topics/user_application.html?highlight=app.route#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

 ![image](https://discuss-cdn.tryton.org/uploads/default/original/1X/d6a41d939cbc78e4a3273ab967f2096dc6f7799f.png)

I hope i am sending in right format

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [July 23, 2020, 2:03pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/2 "2020-07-23T14:03:57Z")

</div>

Is the file where the route is declared imported in the ` __init__.py` of the module?

---

<div class="post-metadata">

**Author:** ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)\
**Post date:** [July 23, 2020, 3:19pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/3 "2020-07-23T15:19:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![josesalvador](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/josesalvador/32/602_2.png) [@josesalvador](https://discuss.tryton.org/u/josesalvador)\
**Post date:** [July 23, 2020, 3:21pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/4 "2020-07-23T15:21:44Z")

</div>

> [@deathrake](#):
>
> i cant find the project directory in the container

You can take a look to the [Dockerfile](https://hg.tryton.org/tryton-docker/file/tip/5.6/Dockerfile) for Tryton in order to understand how and where Tryton is deployed

---

<div class="post-metadata">

**Author:** ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)\
**Post date:** [July 23, 2020, 5:52pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/5 "2020-07-23T17:52:25Z")

</div>

thanks a lot i was able to find the Project Directory

@ced i tried importing that file in \_\_init\_\_.py but still same issue persist

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [July 23, 2020, 6:41pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/6 "2020-07-23T18:41:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)\
**Post date:** [July 24, 2020, 11:06am UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/7 "2020-07-24T11:06:21Z")

</div>

Hey @ced

Thanks for your help i tried importing file in ` __init__.py`

My ` __init__.py`

```auto
    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'):
        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 `test.py`

```auto
    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

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [July 24, 2020, 11:22am UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/8 "2020-07-24T11:22:42Z")

</div>

> [@deathrake](#):
>
> Thanks for your help i tried importing file in ` __init__.py`

When I talked about the ` __init__.py` file, I was not talking about the `trytond/ __init__.py` file but the ` __init__.py` of your [custom module](https://docs.tryton.org/projects/server/en/latest/topics/modules/index.html#topics-modules).

---

<div class="post-metadata">

**Author:** ![deathrake](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@deathrake](https://discuss.tryton.org/u/deathrake)\
**Post date:** [July 24, 2020, 12:17pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/9 "2020-07-24T12:17:33Z")

</div>

thanks @ced  
i was able to get it working by implementing same code in routes.py 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

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [July 24, 2020, 12:22pm UTC](https://discuss.tryton.org/t/rest-api-metthod-not-allowed-405-error/3058/10 "2020-07-24T12:22:20Z")

</div>

> [@deathrake](#):
>
> although i was not required to send bearer token

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