Pre-recorded question

Question #236
How to make AJAX request from Python?
Answer

AJAX requests can be easily perfomed with the Requests library for Python. The following example make a simple echo request from Postman Echo:

from requests import Session
response = Session().post(
    url='https://postman-echo.com/post',    
    data={ 'foo1': "bar1", 'foo2': "bar2" }
)
print (response.text)

The expected response is a JSON string like:

{'args': {},
 'data': '',
 'files': {},
 'form': {'foo1': 'bar1',
          'foo2': 'bar2'},
 'headers': {'accept': '*/*',
...




2 events in history
Answer by Alphonsio 10/04/2020 at 11:02:28 AM

AJAX requests can be easily perfomed with the Requests library for Python. The following example make a simple echo request from Postman Echo:

from requests import Session
response = Session().post(
    url='https://postman-echo.com/post',    
    data={ 'foo1': "bar1", 'foo2': "bar2" }
)
print (response.text)

The expected response is a JSON string like:

{'args': {},
 'data': '',
 'files': {},
 'form': {'foo1': 'bar1',
          'foo2': 'bar2'},
 'headers': {'accept': '*/*',
...




Question by Alphonsio 10/04/2020 at 10:54:57 AM
How to make AJAX request from Python?
# ID Query URL Count

Icons proudly provided by Friconix.