Kleiton Kurti
Kleiton Kurti

Reputation: 153

Python3 add multiple headers in a request

I want to send a request using these custom 2 Headers:

Host: website.com
Origin: anotherwebsite.com

Here is my python3 code:

headers = [("Host" , "https://website.com",
           ("Origin" , "https://evil.com")]
request = requests.get(site, headers=headers)

When executed it shows this error: 'list' object has no attribute 'items' and it refers to this line request = requests.get(site, headers=headers)

Any help is highly appreciated, thank you in advanced.

Upvotes: 0

Views: 830

Answers (1)

Andy Dalton
Andy Dalton

Reputation: 242

I usually use a dictionary:

headers = {
    "Host": "https://website.com",
    "Origin": "https://evil.com",
}

request = requests.get(site, headers=headers)

Upvotes: 1

Related Questions