Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type definitions for hubspotClient.files.filesApi.upload() #476

Open
MattVaughan-Jones opened this issue Mar 19, 2024 · 2 comments

Comments

@MattVaughan-Jones
Copy link

MattVaughan-Jones commented Mar 19, 2024

All arguments are optional in the type declaration file, but I receive an error saying that options is a required field.

The declaration file stipulates:

upload(file?: HttpFile, folderId?: string, folderPath?: string, fileName?: string, charsetHunch?: string, options?: string, _options?: Configuration): Promise<any>;

but it is unclear how the options argument is to be passed in. Does anyone know?

I currently have the following, which is not working:
await hubspotClient.files.filesApi.upload( { data: file, name: 'test upload' }, '160809862233', {access: 'PUBLIC_NOT_INDEXABLE'} );

@M-erb
Copy link

M-erb commented Apr 26, 2024

Hey @MattVaughan-Jones I ran into the same issue and I was able to get past it, hope this helps! I rammed my head against my keyboard late into the night but I was able to find an older version of the API docs and found a definition for the options object here: https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file. Scroll down to the options object heading. Below is an example of what I ended up writing that worked.

const file = fileBuffer
const fileName = 'file.pdf'
const options = JSON.stringify({ access: 'PRIVATE', overwrite: false })

const res = await hsClient.files.filesApi.upload(
    { data: file, name: fileName },
    undefined,
    '/generated-files',
    fileName,
    undefined,
    options
) // notice that there are "undefined" values declared for the arguments that I did not want to set

On another note though, this is either a documentation fail or maybe there were supposed to be some defaults set that would allow this to be optional. In either case, this is a bug that needs to be addressed.

@MattVaughan-Jones
Copy link
Author

Oh brilliant! Thanks for following up with the solution, @M-erb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants