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.










share|improve this question









New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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















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.










share|improve this question









New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • 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













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.










share|improve this question









New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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






share|improve this question









New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Morvader

1,68022440




1,68022440






New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Luke Han

11




11




New contributor




Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Luke Han is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • 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




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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Luke Han is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















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






























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.










 

draft saved


draft discarded


















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.















 


draft saved


draft discarded














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





















































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







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?