M
M
Master Ruby2022-01-09 23:28:20
Python
Master Ruby, 2022-01-09 23:28:20

Why is it giving a 400 error?

Gives a 400 error

import http.client
import urllib.parse

headers = {
    "accept": "application/json",
    "accept-encoding": "gzip, deflate, br",
    "Connection": "keep-alive",
    "content-type": "application/json",
    "Host": "lds-api-sites.ligastavok.ru",
    "Origin": "https://www.ligastavok.ru",
    "Referer": "https://www.ligastavok.ru/",
    "Sec-Fetch-Dest": "empty",
    "User-Agent": "Chrome/97.0.4692.71 Safari/537.36",

}

params = urllib.parse.urlencode(
    {"limit": 10, "ns": "live", "view": "sport", "widgetVideo": False, "exceptEventIds": []}
)

conn = http.client.HTTPConnection("lds-api-sites.ligastavok.ru",443)
conn.request("POST", "/rest/events/v6/actionLines", body=params, headers=headers)
response = conn.getresponse()
print(response.status, response.reason)

data = response.read()
print(data)

conn.close()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2022-01-09
@Dunaevlad

start with HTTPConnection vs HTTPSConnection

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question