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

v4.0.1 addFileAttachment not sending data in correct format #44

Closed
Scomodev opened this issue Oct 20, 2023 · 1 comment
Closed

v4.0.1 addFileAttachment not sending data in correct format #44

Scomodev opened this issue Oct 20, 2023 · 1 comment

Comments

@Scomodev
Copy link
Contributor

Scomodev commented Oct 20, 2023

What is the issue?

When adding a file attachment (csv) with v4.0.1, the file is saved to the sheet without correctly parsing characters such as /r/n and is treated as a string. This is due to content-type header being set to application/json as default.

Steps to Reproduce

CODE

var client = require('smartsheet');

var smartsheet = client.createClient({
  accessToken: 'YOUR_ACCESS_TOKEN',
  logLevel: 'info'
});

const myCsvString = `col1,col2,col3
1,2,3
4,5,6`

let options = {}
options.sheetId = YOUR_SHEET_ID
options.fileName = "Test1.csv"
options.fileStream = myCsvString;
options.fileSize = options.fileStream.length;

smartsheet.sheets.addFileAttachment(options);

V4.0.1 Outcome

File downloaded from sheet after using addFileAttachment:
Test1 (1).csv

V3.1.4 Outcome

File downloaded from sheet after using addFileAttachment:
Test1 (2).csv

Potential Cause

'Content-Type': options.contentType || 'application/json',

Hard coding this value to application/octet-stream produced the correct results on par with V3.1.4.

@Scomodev
Copy link
Contributor Author

Fixed in release v4.0.2

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

1 participant