Skip to content

Bug report: spo listitem batch add gives errors when columns contain json objects with multiple properties #5825

@brugh

Description

@brugh

Priority

(Low) Something is a little off

Description

i have an issue with bulk import for m365 spo:

When i import this CSV:

  Title,FormJSON,Created
  Test 123,"{""test"":""123"",""test2"":""234""}",2024-02-01 12:23:34

with

  m365 spo listitem batch add --filepath <CSV file> -u <sharepoint site> -t <listname> --verbose

it gives me an error that the Created column has an invalid format.

This seems due to the comma inside the JSON string because when I remove the test2 property, it works fine.

Seems the csv importer doesn't handle the quotes correctly in case of double quoted strings.

as a workaround i added this to parseCsvToJson in formatting.js:

        let lines = s?.replace(/""/g,'\xFD').split('\n');

and under if(isNaN(value)..)

        obj[key] = lineMatch[index]?.replace(/\xFD/g,'"');

which seems to solve my issue for now..

Steps to reproduce

as described above

Expected results

Getting a DONE message for correctly imported list of items

Actual results

Writing away 1 items.
{"error":"Creating some items failed with the following errors: \r\n- Line 2: Created - You must specify a valid date within the range of 1/1/1900 and 12/31/8900."}

Diagnostics

No response

CLI for Microsoft 365 version

"v7.4.0-beta.d2ff47d"

nodejs version

v20.9.0

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

No response

Additional Info

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions