Solution skill
Square API for invoice attachments 'Received multiple request parts. Please only supply zero or one `parts` of type appl
Complete solution
Shows how to fix square API for invoice attachments 'Received multiple request parts. Please only supply zero or one `parts` of type appl. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "`` *** square.core.api\error.ApiError: status\code: 400, body: {'errors': [{'category': 'INVALID\REQUEST\ERROR', 'code': 'INVALID\CONTE": 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 create\invoice\attachment so the multipart part carries the right content type.
``` *** 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.' }] } ```Steps
- 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.
When to use
You are seeing this: The 'Received multiple request parts' error on invoice attachments means the server cannot parse the file's Content-Type. Use this skill when you run into "Square API for invoice attachments 'Received multiple request parts. Please only supply zero or one parts of type appl".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/square/square-python-sdk/issues/150:
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 2 · 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 'Received multiple request parts. Please only supply zero or one `parts` of type appl <span>— Vectle</span></a>