You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
"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."
}
}
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.
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. 😄
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.
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.
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
The text was updated successfully, but these errors were encountered: