Hryhorii Pavlenko
Hryhorii Pavlenko

Reputation: 3910

How to make a post request with specific parameters

Is it possible to access raw data from this site using python requests?

In the network tab, I found getAllDeclaration item that has POST method and specifies requests payload parameters.

So far I've tried this:

url = "https://cab.vkksu.gov.ua/rest/qa2_resultLatest/"
payload = {"PIB": "Іванов Іван Іванович", "docTypeID": "3000000768001", "yearString": "2018", "pageNum": 0}
# `docTypeID` I got from https://cab.vkksu.gov.ua/rest/qa2_interview/getInterviewType"
requests.post(url, payload)
# results in 400 response code

Upvotes: 1

Views: 74

Answers (2)

Emmanuel Mtali
Emmanuel Mtali

Reputation: 4963

Try the following code, pretty sure you messed up the url part.

import requests

url = "https://cab.vkksu.gov.ua/rest/qa2_resultLatest/getAllDeclaration" 
data = {
    "PIB": "Іванов Іван Іванович", 
    "docTypeID": "3000000768001", 
    "yearString": "2018", 
    "pageNum": 0
}
response = requests.post(url, json=data)

print(response.json())

Upvotes: 2

Hayat
Hayat

Reputation: 1639

Try this:

import json
url = "https://cab.vkksu.gov.ua/rest/qa2_resultLatest/"
payload = {"PIB": "Іванов Іван Іванович", "docTypeID": "3000000768001", "yearString": "2018", "pageNum": 0}
header = "application/json"
mydata = json.dumps(payload)
# `docTypeID` I got from https://cab.vkksu.gov.ua/rest/qa2_interview/getInterviewType"
resp = requests.post(url, mydata,header)
print(resp.content)

Upvotes: 0

Related Questions