D
D
Dmitry Loginov2022-02-01 20:12:28
Python
Dmitry Loginov, 2022-02-01 20:12:28

How to fix error: "code":-32700,"message":"Parse error"?

import urllib3
import urllib.parse
import urllib.request
import zlib


data = bytes(urllib.parse.urlencode({"id":"1","jsonrpc":"2.0","method":"item.GetItemPhoneV1","params":{"meta":{"platform":"web","language":"ru"},"id":4562643838,"itemType":"Listing"}}), encoding='utf-8')

headers={"Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
    "Content-Length": "147",
    "Content-Type": "text/plain",
    "Cookie": "dfuid=ba401084-3c5b-4d03-96cf-224e78a28556; _ga=GA1.2.540627339.1642173394; rrpvid=168246429700007; cto_optout=1; rcuid=5e249f423a11c9000101e36b; _gid=GA1.2.257072888.1643640331; rr-viewItemId=2308834619; rrviewed=2308834619; _gat=1; rrlevt=1643728096258",
    "Origin": "https://www.domofond.ru",
    "Referer": "https://www.domofond.ru/",
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.175 Safari/537.36",
    "X-Request-Id": "a4ffe504-5907-41b5-aafe-416f5707929a"
    }

url = "https://api.domofond.ru/rpc"
req = urllib.request.Request(url, headers=headers, data=data, method='POST')
res = urllib.request.urlopen(req)
decompressed_data=zlib.decompress(res.read(), 16+zlib.MAX_WBITS)
print(decompressed_data)


Response:
{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}

I understand that something is wrong in the request

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question