Python Forum
How to get json data by request with header? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: How to get json data by request with header? (/thread-35466.html)



How to get json data by request with header? - dokipo - Nov-06-2021

Hello, I would like to go to page https://losoviny.iamroot.eu/part_one and write json text from there.
End at first I must login in https://losoviny.iamroot.eu/part_one_login and use
details in header.

But if If I run code I see:

Error:
raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Do you know how to rewrite it?
(Header data are correct)

Thank you

There is my code:

import json
import requests

headers = {
    'username': 'Loskarlos',
    'password':  'JednohoDneOvladnuKSI'
}


response = requests.post('https://losoviny.iamroot.eu/part_one_login', headers=headers)
        
response_get = requests.get('https://losoviny.iamroot.eu/part_one ')
    
response_get = json.loads(response_get.json())
    
print(response_get)