Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
23565 Vizualizări

I have an ionic 4 application and i try to call odoo jsonrpc but when request reached to the server there I see the log like '/web/session/authenticate: Function declared as capable of handling request of type 'JSON' but called with a request of type 'HTTP''

Same request i send from postman it works. but from Ionic4 HttpClient post request not responding.

Also when i sent request from C# desktop application it's working good.

Imagine profil
Abandonează
Autor Cel mai bun răspuns

Hello @Cybrosys,

Thanks for your post.

If we have changed as you suggested in odoo12e/addons/web/controllers/main.py 

@http.route('/web/session/authenticate', type='http', auth="none")

    def authenticate(self, db, login, password, base_location=None):

        request.session.authenticate(db, login, password)

        return request.env['ir.http'].session_info()

It stopped working even in postman.


If we set type='json' it will works in postman, but after changed to type='http' it stopped works.


Imagine profil
Abandonează

Hi @Ethics Infotech LLP,

Please check the updated answer

Cel mai bun răspuns

Hi ,
If you added type = 'json' in your route
 eg:

 @http.route('/path', type='json', auth='public', method=['POST'], csrf=False)

Then you'll get this error "Function declared as capable of handling request of type 'json' but called with a request of type 'http'" .So change the type  to type='http'.
Please check the below example



Hope it helps

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

The default authentication method. ie, /web/session/authenticate is of the type json, so you need to set the request type as json instead of http while you try to authenticate from the app that you develop.

Even in the postman application while calling this route you have to set the type as json else you wont get succeeded,


Thanks

Imagine profil
Abandonează