Skip to content
← Back to activity

Immutable solution version

Square API for invoice attachments 'Received multiple request parts. Please only supply zero or one `parts` of type appl

Version 1Sign in to save

Complete solution

The 'Received multiple request parts' error on invoice attachments means the server cannot parse the file's Content-Type. The SDK's File type lets you set it explicitly: pass a tuple like `(os.path.basename(pdf_filepath), open(pdf_filepath, 'rb'), 'application/pdf')` as image_file in `create_invoice_attachment` so the multipart part carries the right content type.

Square API for invoice attachments 'Received multiple request parts. Please only supply zero or one parts of type appl

The 'Received multiple request parts' error on invoice attachments means the server cannot parse the file's Content-Type. The SDK's File type lets you set it explicitly: pass a tuple like (os.path.basename(pdf_filepath), open(pdf_filepath, 'rb'), 'application/pdf') as imagefile in `createinvoice_attachment` so the multipart part carries the right content type.

Context from the issue

gh:square/square-python-sdk#150: Issue square/square-python-sdk#150 (closed, 6 comments): Describe the bug I am continually getting the multiple request error when invoking invoices.createinvoiceattachment `` *** square.core.api_error.ApiError: status_code: 400, body: {'errors': [{'category': 'INVALID_REQUEST_ERROR', 'code': 'INVALID_CONTENT_TYPE', 'detail': 'Received multiple request parts. Please only supply zero or one parts of type application/json.' }] } `` Expected behavior The API should attach a file in dev to an invoice and return a successful attachment JSON To Reproduce 1. setup python app to use square package using pip 2. invoke createinvoiceattachm

Evidence

Issue gh:square/square-python-sdk#150: the reporter asked: Issue square/square-python-sdk#150 (closed, 6 comments): Describe the bug I am continually getting the multiple request error when invoking invoices.createinvoiceattachment `` *** square.core.api_error.ApiError: status_code: 400, body: {'errors': [{'category': 'INVALID_REQUEST_ERROR', 'code': 'INVALID_CONTENT_TYPE', 'detail': 'Received multiple request parts. Please only supply zero or one parts of type application/json.' }] } **Expected behavior** The API should attach a file in dev to an invoice and return a successful attachment JSON **To Reproduce** 1. setup python app to use square package using pip 2. invoke create_invoice_attachm The verified answer was: The 'Received multiple request parts' error on invoice attachments means the server cannot parse the file's Content-Type. The SDK's File type lets you set it explicitly: pass a tuple like (os.path.basename(pdffilepath), open(pdffilepath, 'rb'), 'application/pdf') as image_file in createinvoiceattachment` so the multipart part carries the right content type. Evidence thread: https://github.com/square/square-python-sdk/issues/150

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_jMJTzmt3KbX5DUzd5xgDeQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Square API for invoice attachments &#39;Received multiple request parts. Please only supply zero or one `parts` of type appl <span>— Vectle</span></a>