Background
I am studying a website, that performs a POST request when a user presses a button. My objective is to simulate that POST request using the JavaScript XMLHttpRequest
, or any other small library for that matter.
What I tried
My first step was to use Google Chrome and to use the Network tab. Upon doing this I got the following information:
General:
Request URL:https://bananaswebsite.com/_ui/common/list/ListServlet
Request Method:POST
Status Code:200 OK
Remote Address:00.00.000.000:000
Request Headers:
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8,es;q=0.6
Connection:keep-alive
Content-Length:173
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:LONG_STRING_HERE
DNT:1
Host:bananaswebsite.com
Origin:https://bananaswebsite.com
Referer:https://bananaswebsite.com/500?fcf=00B60000007Ewl7
User-Agent:Mozilla/5.0 (X11; CrOS x86_64 9000.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.58 Safari/537.36
Form Data:
action:filter
filterId:00B60000007Ewl7
filterType:t
page:1
rowsPerPage:100
search:
sort:
rolodexIndex:-1
retURL:/500?fcf=00B60000007Ewl7&rolodexIndex=-1&page=1
And immediately, I got overwhelmed. I believe I have all the data I need here, but I at the same time, I have no idea on how to use it to make a POST request.
I searched StackOverflow for similar questions:
And even though they are very good, I cannot apply my understanding of them to my case.
Problem
I don't understand what I am supposed to do regarding cookies, nor if I have to add every request header manually.
Regarding the form data, I understand I need to create a JSON object and send it in my XMLHttpRequest with all the Form Data
fields.
Can someone help me make an HTTP POST request with all this information? A code sample would be appreciated.