POST-query via Postman work, but query via python requests don't work

Viewed 30

In an isolated network at the enterprise, was deployed API server with a self-signed certificate. Access to API-server via Postman works. But if I try to connect to server via Python, then the body request seems like empty, but i'm not sure

import requests
import json
import http.client

from urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)

url = "https://{...}:{...}/GetData"


payload = json.dumps({
    "Start": 60,
    "Count": 2
})

headers = {
    'Host': '...',       
    'X-Forwarded-Proto': 'https',
    'Connection': 'keep-alive',
    'Content-Length': str(len(payload)),
    'Content-Type': 'application/json',
    'Accept': '*/*',
    'Accept-Encoding': 'gzip, deflate, br'
}

response = requests.post(
        url,
        headers=headers,
        json=payload,
        verify=False
        )
print(response.text)

P.S. I tried to use data instead json but it didn't help. Api-server don't use authentication for this url.

0 Answers
Related