Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions instaparser/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def __init__(self, api_key: str, base_url: str | None = None):
self.base_url = base_url or self.BASE_URL
self.headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
}

def __repr__(self) -> str:
Expand Down Expand Up @@ -157,14 +156,14 @@ def _request(
url = f"{url}?{urlencode(params)}"

data = None
headers = self.headers
headers = self.headers.copy()

if multipart_fields or multipart_files:
data, content_type = _encode_multipart_formdata(multipart_fields or {}, multipart_files or {})
headers = headers.copy()
headers["Content-Type"] = content_type
elif json_data is not None:
data = json.dumps(json_data).encode("utf-8")
headers["Content-Type"] = "application/json"

req = Request(url, data=data, headers=headers, method=method)
response: HTTPResponse = urlopen(req)
Expand Down
1 change: 0 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def test_base_url(self):
def test_headers(self):
client = InstaparserClient(api_key=API_KEY)
assert client.headers["Authorization"] == f"Bearer {API_KEY}"
assert client.headers["Content-Type"] == "application/json"


class TestReadJson:
Expand Down