Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Redirect to external url via http POST

By
Martin Varela
on 7/6/15, 11:09 AM 2,636 views

I need to redirect Odoo to an external website via http POST request.

Is this possible?

I can´t find any examples for it.

ir.actions.act_url only works for http GET.

Any ideas? 

0
GARY F WALTERS
On 7/7/15, 3:13 AM

By default, all links clicked through a browser are GET requests.  In order for a browser to send a POST request, you'll need to create custom JavaScript to POST the data to the URL.

You could also create a custom web controller to receive the GET request locally, and then issue the POST request in python to the external URL.  

Thanks. I´m trying with the web controller but I can´t issue the POST request in python. How do you change the request method to POST and redirect to it? @http.route('/redirect_post', type='http', auth="none", methods=['GET']) def redirect_post(self, **post): cr, uid, context = request.cr, request.uid, request.context #redirect to an external url changing to POST and adding parameters

Martin Varela
on 7/7/15, 1:16 PM
Here's an example using HTTP for Humans (http://docs.python-requests.org/)

import requests
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.post("http://httpbin.org/post", data=payload)

On Tue, Jul 7, 2015 at 11:16 AM, Martin Varela <martin_varela85-hotmail.com@mail.odoo.com> wrote:

Thanks. I´m trying with the web controller but I can´t issue the POST request in python. How do you change the request method to POST and redirect to it? @http.route('/redirect_post', type='http', auth="none", methods=['GET']) def redirect_post(self, **post): cr, uid, context = request.cr, request.uid, request.context #redirect to an external url changing to POST and adding parameters

--
Martin Varela
Sent by Odoo Inc. using Odoo access your messages

GARY F WALTERS
on 7/7/15, 2:08 PM

I've tried that, but when I return de request "r" raises a warning and then an error: WARNING openerp.http: returns an invalid response type for an http request ERROR werkzeug: Error on request: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi execute(self.server.app) File "/usr/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute application_iter = app(environ, start_response) File "/usr/lib/python2.7/site-packages/openerp/service/server.py", line 281, in app return self.app(e, s) File "/usr/lib/python2.7/site-packages/openerp/service/wsgi_server.py", line 216, in application return application_unproxied(environ, start_response) File "/usr/lib/python2.7/site-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied result = handler(environ, start_response) File "/usr/lib/python2.7/site-packages/openerp/http.py", line 1215, in __call__ return self.dispatch(environ, start_response) File "/usr/lib/python2.7/site-packages/openerp/http.py", line 1189, in __call__ return self.app(environ, start_wrapped) File "/usr/lib/python2.7/site-packages/werkzeug/wsgi.py", line 579, in __call__ return self.app(environ, start_response) File "/usr/lib/python2.7/site-packages/openerp/http.py", line 1362, in dispatch return response(environ, start_response) TypeError: 'Response' object is not callable

Martin Varela
on 7/7/15, 3:31 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/6/15, 11:09 AM
Seen: 2636 times
Last updated: 7/11/15, 2:10 PM