Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
23567 Visualizzazioni

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
Abbandona
Autore Risposta migliore

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
Abbandona

Hi @Ethics Infotech LLP,

Please check the updated answer

Risposta migliore

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
Abbandona
Risposta migliore

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
Abbandona