intuit / intuit/oauth-jsclient
Handling multipart/form data to upload items to the attachable endpoints.
- Dominant language
- JavaScript
- Stars
- 145
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
I was wondering if this library supports uploading files to the attachable endpoint? Currently if I try to do this.
`const image = images[0];
const imageFile = fs.createReadStream(image.rawInfo.path);
const uploadedImage = await QBFileUpload(
image.rawInfo.filename,
image.rawInfo.mimetype,
imageFile,
'Item',
newQBProduct.Id
);
console.log({ uploadedImage });
const form = new FormData();
form.append('file_content_01', imageFile, {
filename: image.rawInfo.filename,
contentType: image.rawInfo.mimetype,
});
form.append(
'file_metadata_01',
JSON.stringify({
AttachableRef: [
{
EntityRef: { type: 'Item', value: newQBProduct.Id },
},
],
ContentType: image.rawInfo.mimetype,
FileName: image.rawInfo.filename,
}),
{
contentType: 'application/json',
filename: 'file_metadata_01',
}
);
console.log({ formHeader: form.getHeaders() });
const imageResponse = await qbClient.makeApiCall({
url: `${process.env.QB_API_URL}/v3/company/${process.env.QB_COMPANY_ID}/upload?minorversion=69`,
method: 'POST',
headers: {
...form.getHeaders(),
},
body: form,
});`
I get a response error:` Content length missing in request","Detail":"We cannot find the content-length header in the request.","code":"6020"}`
Thanks
CES
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing qbClient.makeApiCall and the QBFileUpload entry point, then reproduce the multipart request against the attachable upload endpoint using the provided FormData example. Check how request headers and content length are handled; done means the upload request includes the required content-length header and succeeds without error 6020.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100