My use case is: create an API method which POSTs data to a 3rd party endpoint. The endpoint returns a 302 Redirect which is basically an OTP validation screen. I’ve tried out the following snippet but I’m unable to make it working fully.
@frappe.whitelist(allow_guest=True)
def redirect_otp():
url = 'http://3rdpartypage.com'
# werkzeug Response object
response = Response()
response.mimetype = 'application/json'
response.charset = 'utf-8'
payload = {'some': 'data'}
response.data = json.dumps(payload)
return werkzeug.utils.redirect(url)
How do I POST
the data with the payload to the url and then automatically redirect the user ? Also, the redirection is handled by 3rd party gateway. I just need to POST the data to it and let the user see the OTP page.