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

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

Closed
preavy opened this issue Jun 15, 2022 · 5 comments
Closed
Assignees
Milestone

Comments

@preavy
Copy link

preavy commented Jun 15, 2022

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

@waldekmastykarz
Copy link
Member

Thank you for reporting the issue and sorry to hear you're running into trouble. We'll investigate it asap

@Jwaegebaert
Copy link
Contributor

Hi @preavy, I was able to reproduce your problem so I did a little digging to see how we can solve this for you.

First of all, with my testing I got the following results. On my test environment I have a list called Demo with 2 columns. Column SLT is a single line of text and column Number is, well a number column.

afbeelding

As you can see, the results I got are quite similar towards your findings.

But not to worry. I found a solution for you, but this requires an update towards the CLI. So for this, I will open a PR and as soon as this is approved you will be able to modify number columns and text columns with only numbers. 😄

@martinlingstuyl
Copy link
Contributor

martinlingstuyl commented Jun 26, 2022

Thanks for reporting this @preavy! And thanks for diving into it @Jwaegebaert!

@preavy
Copy link
Author

preavy commented Jun 27, 2022

Thanks for this. My use case was copying items from one SharePoint list to another. I was aiming to use m365 cli alone to do this but in the meantime I was able to work around this issue by mixing in Set-PnPListItem from PnP.PowerShell. I appreciate you looking into the issue.

@preavy
Copy link
Author

preavy commented Jun 30, 2022

Thanks everyone.

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