Skip to content

Bug report: "m365 spo listitem set" issues with Number and Single Line of Text #3405

@preavy

Description

@preavy

Description

There are two closely related issues. One is setting a Single Line of Text with a string which contains something which looks like an integer. The other is simply setting a Number.

If you try to set the value of a Single Line of Text with a string as such "example", it will work. If you used "123example", it will work. If you use "123", it will say:
Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

  1. If you try to set the value of Number, it doesn't matter if you put the value in quotes or not, you get
    Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

Steps to reproduce

Create a list with a Single Line of Text called Name and a Number called Total.

C:>m365 spo listitem set -u "https://mytenant.sharepoint.com/sites/my-site" --listTitle "Test" --id 1 --Name "123"
Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

C:>m365 spo listitem set -u "https://mytenant.sharepoint.com/sites/my-site" --listTitle "Test" --id 1 --Total "123"
Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

C:>m365 spo listitem set -u "https://mytenant.sharepoint.com/sites/my-site" --listTitle "Test" --id 1 --Total 123
Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

Expected results

Should be able to set a Single Line of Text to a string value "123". Should be able to set a Number to a value 123.

Actual results

Error: Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details.

Diagnostics

In both cases, the request contains a FieldValue which has no quotes

"data": {
"formValues": [
{
"FieldName": "Name",
"FieldValue": 123
}
]
}

"data": {
"formValues": [
{
"FieldName": "Total",
"FieldValue": 123
}
]
}

and the response

"status": 400,
"statusText": "Bad Request",

"error": {
"odata.error": {
"code": "-1, Microsoft.Data.OData.ODataException",
"message": {
"lang": "en-US",
"value": "Cannot convert a primitive value to the expected type 'Edm.String'. See the inner exception for more details."
}
}

CLI for Microsoft 365 version

v5.3.0

nodejs version

v14.19.0

Operating system (environment)

Windows

Shell

cmd

cli doctor

{
"os": {
"platform": "win32",
"version": "Windows 10 Enterprise",
"release": "10.0.19044"
},
"cliVersion": "5.3.0",
"nodeVersion": "v14.19.0",
"cliAadAppId": "31359c7f-bd7e-475c-86db-fdb8c937548e",
"cliAadAppTenant": "common",
"authMode": "DeviceCode",
"cliEnvironment": "",
"cliConfig": {},
"roles": [],
"scopes": [
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.Send",
"Reports.Read.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.Read.All",
"profile",
"openid",
"email",
"AllSites.FullControl",
"AppCatalog.ReadWrite.All",
"Directory.AccessAsUser.All",
"Directory.ReadWrite.All",
"Group.ReadWrite.All",
"IdentityProvider.ReadWrite.All",
"Mail.Send",
"Reports.Read.All",
"TermStore.ReadWrite.All",
"User.Invite.All",
"User.Read.All"
]
}

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