Closed haislip closed 3 years ago
Thanks, @haislip for the contribution. This PR will go in our next release.
hi @abisalehalliprasan
Any idea when this will be published over npm? Seems like you merged it but i think it's not published yet.
The /pdf
route is broken until this is pushed to NPM. Not that I'm part of the dev team, but I just reviewed and verified it and it looks good, and there is currently no non-patching workaround to this afaik.
@sdegutis : Just curious what is the transport that you passed to the makeApiCall
method ?
Would it be similar to :
oauthClient
.makeApiCall({ url: `${url}v3/company/${companyID}/invoice/${invoiceNumber}/pdf?minorversion=59` , transport: popsicle.createTransport({type: "buffer"})})
Yep
I get a server error. wondering if the transport
parameter that I have passed is correct :
response: Response {
Url: [Url],
rawHeaders: [Array],
body: <Buffer 7b 22 46 61 75 6c 74 22 3a 7b 22 45 72 72 6f 72 22 3a 5b 7b 22 4d 65 73 73 61 67 65 22 3a 22 41 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 65 72 72 6f ... 184 more bytes>,
status: 500,
statusText: 'Server Error'
},
body: <Buffer 7b 22 46 61 75 6c 74 22 3a 7b 22 45 72 72 6f 72 22 3a 5b 7b 22 4d 65 73 73 61 67 65 22 3a 22 41 6e 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 65 72 72 6f ... 184 more bytes>,
json: { Fault: [Object], time: '2021-05-26T14:33:13.224-07:00' },
intuit_tid: '1-60aebe99-2bd8211b0a8e83d913308d52'
},
originalMessage: 'Response has an Error',
error: 'Server Error',
error_description: 'Server Error',
intuit_tid: '1-60aebe99-2bd8211b0a8e83d913308d52'
@sdegutis : I did not pass the Accept
header also as application/pdf
.makeApiCall({ url: `${url}v3/company/${companyID}/invoice/2/pdf?minorversion=59` , headers:{'Content-Type': 'application/pdf','Accept':'application/pdf'}, transport: popsicle.createTransport({type: 'buffer'})})
This returns a binary BLOB for the pdf response. Thanks for your help. I am good here 👍
https://github.com/intuit/oauth-jsclient/issues/97
In order to save the PDF generated from the APIs properly, the transport passed into the popsicle API needs to be one of type "buffer" instead of "text" (which is the default). This changes keeps the default of using "text", but allows the calling function to pass in the override.