Skip to content

Commit 2b30c04

Browse files
author
Jeremi Joslin
committed
Add headers to the request if needed, so creating a pad work
1 parent 9f3fe03 commit 2b30c04

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hackpad_api/hackpad.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def site_options(self):
115115
api_link = 'options'
116116
return self.do_api_request(api_link, 'GET')
117117

118-
def do_api_request(self, path, method, post_data={}, body='', content_type='text/plain'):
118+
def do_api_request(self, path, method, post_data={}, body='', content_type=None):
119119
method = method.upper()
120120
hackpad = {}
121121
try:
@@ -128,18 +128,21 @@ def do_api_request(self, path, method, post_data={}, body='', content_type='text
128128
'client_key': self.consumer_key,
129129
'client_secret': self.consumer_secret
130130
}
131+
132+
headers = {}
133+
if content_type:
134+
headers['content-type'] = content_type
131135

132136
for key in post_data.keys():
133137
params[key] = post_data[key]
134138

135139
hackpad_api = OAuth1Session(**params)
136140

137141
if method == 'POST':
138-
139-
r = hackpad_api.post(path, data=body)
142+
r = hackpad_api.post(path, data=body, headers=headers)
140143
hackpad = r.json()
141144
else:
142-
r = hackpad_api.get(path)
145+
r = hackpad_api.get(path, headers=headers)
143146

144147
try:
145148
hackpad = r.json()

0 commit comments

Comments
 (0)