convert fiddler post to python request.post
up vote
0
down vote
favorite
i am using fiddler3 to capture the data flow during my browser, and i want to make a post using python request modulus.
The post information i could find in Fiddler is:
URL:
https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders
Request Method: POST
Request Header:
Host: shippingmanager.bpost.be
Connection: keep-alive
Content-Length: 586
Origin: https://shippingmanager.bpost.be
language: en
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
token: c087c667-7580-43b9-8bce-0c25f8377b8a
accountId: 110492
Referer: https://shippingmanager.bpost.be/ShmFrontEnd/start
Accept-Encoding: gzip, deflate, br
Accept-Language: en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4
Cookie: JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4; _acl=YWRtaW46bm8=; _ga=GA1.3.809755681.1542326259; _gid=GA1.3.1523310150.1542326259
Request body:
{"reference":"1542362877BW24387","costCenter":"","totalPriceInEuroCent":"11000","weight":"2000","deliveryMethodId":7,"orderLines":,"customer":{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},"selectedServices":,"priceOverrides":[{"priceZone":"Z3","price":3400}],"extra":"","extraSecure":"","shopHandlingInstruction":"","additionalCustomerReference":""}
If i tried to compose a POST using fiddler, the Response looks good. However, i got errors using Python Request from the Server with a 400 status code. Here is my python code:
import requests
import bs4
post_url = ' https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders'
headers ={"Host": "shippingmanager.bpost.be",
"Connection": "keep-alive",
"Content-Length": "586",
"Origin": "https://shippingmanager.bpost.be",
"language": "en",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/66.0.3359.181 Safari/537.36",
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, */*",
"token": "c087c667-7580-43b9-8bce-0c25f8377b8a",
"accountId": "110492",
"Referer": "https://shippingmanager.bpost.be/ShmFrontEnd/start",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4",
}
cookies = {"JSESSIONID":"JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4",
"_acl":"YWRtaW46bm8=",
"_ga":"GA1.3.809755681.1542326259",
"_gid":"A1.3.1523310150.1542326259"
}
data = {"reference":"1542362877BW24387",
"costCenter":"",
"totalPriceInEuroCent":"11000",
"weight":"2000",
"deliveryMethodId":7,
"orderLines":,
"customer"{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},
"selectedServices":,
"priceOverrides":[{"priceZone":"Z3","price":3400}],
"extra":"",
"extraSecure":"",
"shopHandlingInstruction":"",
"additionalCustomerReference":""
}
r = requests.post(post_url,headers=headers,data = data,cookies=cookies)
print (r.status_code)
soup = bs4.BeautifulSoup(r.text,'html.parser')
print (soup)
I am wondering, probably i did not format the request body well, but I have not idea how to fix.
python request
New contributor
add a comment |
up vote
0
down vote
favorite
i am using fiddler3 to capture the data flow during my browser, and i want to make a post using python request modulus.
The post information i could find in Fiddler is:
URL:
https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders
Request Method: POST
Request Header:
Host: shippingmanager.bpost.be
Connection: keep-alive
Content-Length: 586
Origin: https://shippingmanager.bpost.be
language: en
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
token: c087c667-7580-43b9-8bce-0c25f8377b8a
accountId: 110492
Referer: https://shippingmanager.bpost.be/ShmFrontEnd/start
Accept-Encoding: gzip, deflate, br
Accept-Language: en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4
Cookie: JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4; _acl=YWRtaW46bm8=; _ga=GA1.3.809755681.1542326259; _gid=GA1.3.1523310150.1542326259
Request body:
{"reference":"1542362877BW24387","costCenter":"","totalPriceInEuroCent":"11000","weight":"2000","deliveryMethodId":7,"orderLines":,"customer":{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},"selectedServices":,"priceOverrides":[{"priceZone":"Z3","price":3400}],"extra":"","extraSecure":"","shopHandlingInstruction":"","additionalCustomerReference":""}
If i tried to compose a POST using fiddler, the Response looks good. However, i got errors using Python Request from the Server with a 400 status code. Here is my python code:
import requests
import bs4
post_url = ' https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders'
headers ={"Host": "shippingmanager.bpost.be",
"Connection": "keep-alive",
"Content-Length": "586",
"Origin": "https://shippingmanager.bpost.be",
"language": "en",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/66.0.3359.181 Safari/537.36",
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, */*",
"token": "c087c667-7580-43b9-8bce-0c25f8377b8a",
"accountId": "110492",
"Referer": "https://shippingmanager.bpost.be/ShmFrontEnd/start",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4",
}
cookies = {"JSESSIONID":"JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4",
"_acl":"YWRtaW46bm8=",
"_ga":"GA1.3.809755681.1542326259",
"_gid":"A1.3.1523310150.1542326259"
}
data = {"reference":"1542362877BW24387",
"costCenter":"",
"totalPriceInEuroCent":"11000",
"weight":"2000",
"deliveryMethodId":7,
"orderLines":,
"customer"{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},
"selectedServices":,
"priceOverrides":[{"priceZone":"Z3","price":3400}],
"extra":"",
"extraSecure":"",
"shopHandlingInstruction":"",
"additionalCustomerReference":""
}
r = requests.post(post_url,headers=headers,data = data,cookies=cookies)
print (r.status_code)
soup = bs4.BeautifulSoup(r.text,'html.parser')
print (soup)
I am wondering, probably i did not format the request body well, but I have not idea how to fix.
python request
New contributor
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i am using fiddler3 to capture the data flow during my browser, and i want to make a post using python request modulus.
The post information i could find in Fiddler is:
URL:
https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders
Request Method: POST
Request Header:
Host: shippingmanager.bpost.be
Connection: keep-alive
Content-Length: 586
Origin: https://shippingmanager.bpost.be
language: en
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
token: c087c667-7580-43b9-8bce-0c25f8377b8a
accountId: 110492
Referer: https://shippingmanager.bpost.be/ShmFrontEnd/start
Accept-Encoding: gzip, deflate, br
Accept-Language: en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4
Cookie: JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4; _acl=YWRtaW46bm8=; _ga=GA1.3.809755681.1542326259; _gid=GA1.3.1523310150.1542326259
Request body:
{"reference":"1542362877BW24387","costCenter":"","totalPriceInEuroCent":"11000","weight":"2000","deliveryMethodId":7,"orderLines":,"customer":{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},"selectedServices":,"priceOverrides":[{"priceZone":"Z3","price":3400}],"extra":"","extraSecure":"","shopHandlingInstruction":"","additionalCustomerReference":""}
If i tried to compose a POST using fiddler, the Response looks good. However, i got errors using Python Request from the Server with a 400 status code. Here is my python code:
import requests
import bs4
post_url = ' https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders'
headers ={"Host": "shippingmanager.bpost.be",
"Connection": "keep-alive",
"Content-Length": "586",
"Origin": "https://shippingmanager.bpost.be",
"language": "en",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/66.0.3359.181 Safari/537.36",
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, */*",
"token": "c087c667-7580-43b9-8bce-0c25f8377b8a",
"accountId": "110492",
"Referer": "https://shippingmanager.bpost.be/ShmFrontEnd/start",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4",
}
cookies = {"JSESSIONID":"JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4",
"_acl":"YWRtaW46bm8=",
"_ga":"GA1.3.809755681.1542326259",
"_gid":"A1.3.1523310150.1542326259"
}
data = {"reference":"1542362877BW24387",
"costCenter":"",
"totalPriceInEuroCent":"11000",
"weight":"2000",
"deliveryMethodId":7,
"orderLines":,
"customer"{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},
"selectedServices":,
"priceOverrides":[{"priceZone":"Z3","price":3400}],
"extra":"",
"extraSecure":"",
"shopHandlingInstruction":"",
"additionalCustomerReference":""
}
r = requests.post(post_url,headers=headers,data = data,cookies=cookies)
print (r.status_code)
soup = bs4.BeautifulSoup(r.text,'html.parser')
print (soup)
I am wondering, probably i did not format the request body well, but I have not idea how to fix.
python request
New contributor
i am using fiddler3 to capture the data flow during my browser, and i want to make a post using python request modulus.
The post information i could find in Fiddler is:
URL:
https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders
Request Method: POST
Request Header:
Host: shippingmanager.bpost.be
Connection: keep-alive
Content-Length: 586
Origin: https://shippingmanager.bpost.be
language: en
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Content-Type: application/json;charset=UTF-8
Accept: application/json, text/plain, */*
token: c087c667-7580-43b9-8bce-0c25f8377b8a
accountId: 110492
Referer: https://shippingmanager.bpost.be/ShmFrontEnd/start
Accept-Encoding: gzip, deflate, br
Accept-Language: en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4
Cookie: JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4; _acl=YWRtaW46bm8=; _ga=GA1.3.809755681.1542326259; _gid=GA1.3.1523310150.1542326259
Request body:
{"reference":"1542362877BW24387","costCenter":"","totalPriceInEuroCent":"11000","weight":"2000","deliveryMethodId":7,"orderLines":,"customer":{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},"selectedServices":,"priceOverrides":[{"priceZone":"Z3","price":3400}],"extra":"","extraSecure":"","shopHandlingInstruction":"","additionalCustomerReference":""}
If i tried to compose a POST using fiddler, the Response looks good. However, i got errors using Python Request from the Server with a 400 status code. Here is my python code:
import requests
import bs4
post_url = ' https://shippingmanager.bpost.be/ShmFrontEnd/internal/110492/orders'
headers ={"Host": "shippingmanager.bpost.be",
"Connection": "keep-alive",
"Content-Length": "586",
"Origin": "https://shippingmanager.bpost.be",
"language": "en",
"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/66.0.3359.181 Safari/537.36",
"Content-Type": "application/json;charset=UTF-8",
"Accept": "application/json, text/plain, */*",
"token": "c087c667-7580-43b9-8bce-0c25f8377b8a",
"accountId": "110492",
"Referer": "https://shippingmanager.bpost.be/ShmFrontEnd/start",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en,en-US;q=0.9,zh-CN;q=0.8,zh;q=0.7,it;q=0.6,it-IT;q=0.5,it-CH;q=0.4",
}
cookies = {"JSESSIONID":"JSESSIONID=3098DB975635FC531C284F1F5E1122D8.shm-v001330-frontend-pr-node4",
"_acl":"YWRtaW46bm8=",
"_ga":"GA1.3.809755681.1542326259",
"_gid":"A1.3.1523310150.1542326259"
}
data = {"reference":"1542362877BW24387",
"costCenter":"",
"totalPriceInEuroCent":"11000",
"weight":"2000",
"deliveryMethodId":7,
"orderLines":,
"customer"{"firstName":"xhibg","lastName":"cdegg","company":"1988","street":"9 oxford street","streetNumber":"rm 3","box":"02138","postalCode":"02138","city":"cambridge","country":"US","language":"en","email":"jbgrveneio@foxairmail.com","phoneNumber":"8088254427","privateAddress":"true"},
"selectedServices":,
"priceOverrides":[{"priceZone":"Z3","price":3400}],
"extra":"",
"extraSecure":"",
"shopHandlingInstruction":"",
"additionalCustomerReference":""
}
r = requests.post(post_url,headers=headers,data = data,cookies=cookies)
print (r.status_code)
soup = bs4.BeautifulSoup(r.text,'html.parser')
print (soup)
I am wondering, probably i did not format the request body well, but I have not idea how to fix.
python request
python request
New contributor
New contributor
edited 2 days ago
Morvader
1,68022440
1,68022440
New contributor
asked 2 days ago
Luke Han
11
11
New contributor
New contributor
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago
add a comment |
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Luke Han is a new contributor. Be nice, and check out our Code of Conduct.
Luke Han is a new contributor. Be nice, and check out our Code of Conduct.
Luke Han is a new contributor. Be nice, and check out our Code of Conduct.
Luke Han is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343447%2fconvert-fiddler-post-to-python-request-post%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
See if fiddler has an "export to Python" feature or extension. If not, try exporting it to a cURL command line which is pretty standard and converting that to python code.
– roeen30
2 days ago