Django - Making SMS Auth with custom URL with parameters

31 views Asked by At

I'm working on a company portal website and I'm running into issues that I can't resolve.

What do I want to do?

Creating a page where company employees can request payroll.

First step: When they fill out the form and press the button, the user email, employee ID, etc. I need to make an request an external URL (SAP ERP url) with some parameters like and SAP ERP will send an sms authentication code. After this, the page "must be redirected to another page in order to forward the received SMS code."

On my hand, i've got only 2 url like:

To request for sms auth code:

https://some_url/some_route/..?sap-language=TR&ID=15&USERID=000054

To download payroll:

https://some_url/some_route/..?sap-language=TR&ID=13&USERID=000054&MONTH=02&YEAR=2022&[email protected]

What I tried? Tried to much code but basically
url = f'http://127.0.0.1:8000/sendemail/{user_id}/{email}/'
     # should be replaced sms request url
    
# Django'dan CSRF token'ını al 
csrf_token = get_token(request)

headers = {'X-CSRFToken': csrf_token}

response = requests.post(url, headers=headers)

print(response.status_code)

if response.status_code == 200:
    return redirect('pageSMSCodeInputPage')

return HttpResponse('not OK. error.')
0

There are 0 answers