Skip to Content
Menu
This question has been flagged
3 Replies
20952 Views

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.

Avatar
Discard
Author Best Answer

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.


Avatar
Discard

Hi @Ethics Infotech LLP,

Please check the updated answer

Best Answer

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

Avatar
Discard
Best Answer

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

Avatar
Discard