Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 665621d

Browse files
authored
Merge pull request ej2#66 from subodh-malgonde/master
Fixed attachable upload error
2 parents 9ea60a4 + e34d1b6 commit 665621d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

quickbooks/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import os
1111
from .exceptions import QuickbooksException, SevereException, AuthorizationException
12+
import base64
1213

1314
try:
1415
from rauth import OAuth1Session, OAuth1Service
@@ -254,7 +255,9 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
254255
'Connection': 'close'
255256
})
256257

257-
binary_data = attachment.read()
258+
binary_data = str(base64.b64encode(attachment.read()), 'utf-8')
259+
260+
content_type = json.loads(request_body)['ContentType']
258261

259262
request_body = textwrap.dedent(
260263
"""
@@ -266,13 +269,14 @@ def make_request(self, request_type, url, request_body=None, content_type='appli
266269
267270
--%s
268271
Content-Disposition: form-data; name="file_content_01"
269-
Content-Type: application/pdf
272+
Content-Type: %s
273+
Content-Transfer-Encoding: base64
270274
271275
%s
272276
273277
--%s--
274278
"""
275-
) % (boundary, request_body, boundary, binary_data, boundary)
279+
) % (boundary, request_body, boundary, content_type, binary_data, boundary)
276280

277281
req = self.session.request(
278282
request_type, url, True, self.company_id,

0 commit comments

Comments
 (0)