跳至内容
菜单
此问题已终结
3 回复
23581 查看

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.

形象
丢弃
编写者 最佳答案

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.


形象
丢弃

Hi @Ethics Infotech LLP,

Please check the updated 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

形象
丢弃
最佳答案

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

形象
丢弃