简体   繁体   English

SharePoint REST:列不存在错误

[英]SharePoint REST: Column does not exist error

I'm calling a REST API with a SharePoint Designer workflow on SharePoint online.我在 SharePoint Online 上使用 SharePoint Designer 工作流调用 REST API。 I'm setting the column name with a variable, and when i put the variable into my URL to call it it says "Column [name] does not exist".我正在用一个变量设置列名,当我将该变量放入我的 URL 以调用它时,它说“列 [名称] 不存在”。

Annoying part is when I call just /items?烦人的部分是当我只调用 /items 时? I can see the column in the result, but if I try select it or filter by it I get 'does not exist'.我可以在结果中看到该列,但是如果我尝试选择它或按它过滤,我会得到“不存在”。 I have alot of these columns similarly named, and I get the error for all of them.我有很多类似命名的列,我得到了所有这些列的错误。

I am using the internal name, I have tried adding "OData_" to the front.我正在使用内部名称,我尝试在前面添加“OData_”。 I've tried typing the url manually in the browser and entering values (incase the variable was causing issues) but I get the same error, column does not exist.我试过在浏览器中手动输入 url 并输入值(以防变量导致问题),但我得到了同样的错误,列不存在。 but i can see it them I call all items.但我可以看到它们我称之为所有项目。 :( :(

so I have quite a few columns with naming convention "[Q#] Score [#]" eg "Q4 Score 2".所以我有很多列的命名约定为“[Q#] Score [#]”,例如“Q4 Score 2”。 The internal name that's clearly appearing in the full items results is "Q4_x0020_Score_x0020_2".完整项目结果中清楚显示的内部名称是“Q4_x0020_Score_x0020_2”。

This works: https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle ('Audit')/Items?这有效: https : //MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle ('Audit')/Items?

and I get big full normal REST results that includes the line: 0我得到了包含以下行的完整的正常 REST 结果:0

However if I try: https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle ('Audit')/Items?$Select=Q4_x0020_Score_x0020_2但是,如果我尝试: https://MYSITE.sharepoint.com/sites/portal/intranet/CorpServices/QSR/_api/web/lists/GetbyTitle ('Audit')/Items?$Select=Q4_x0020_Score_x0020_2

Then I get: -2146232832, Microsoft.SharePoint.SPExceptionColumn 'Q4_x0020_Score_x0020_2' does not exist.然后我得到:-2146232832,Microsoft.SharePoint.SPExceptionColumn 'Q4_x0020_Score_x0020_2' 不​​存在。 It may have been deleted by another user.它可能已被其他用户删除。

I expect to be able to select that column (and the dozens like it) but none work.我希望能够选择该列(以及几十个喜欢它的列),但没有任何效果。 I've searched all similar problems on the forum and they've usually got a spelling mistake or forgot the ODATA_ but i cant seem to get the problem.我在论坛上搜索了所有类似的问题,他们通常有拼写错误或忘记了 ODATA_,但我似乎无法解决问题。 Please help.请帮忙。

It seemed to be working intermittently.... So it was in fact just a naming error...... Half of the columns were [Q#]_x0020_Score_x0020_[#] and half were [Q#]_x0020_score_x0020_[#].它似乎在间歇性地工作......所以它实际上只是一个命名错误......一半的列是[Q#]_x0020_Score_x0020_[#],一半是[Q#]_x0020_score_x0020_[#]。 The word "Score" was capitalized on some and not others. “Score”这个词是大写的,而不是其他的。 I Didn't realize the HTTP Calls were case sensitive.我没有意识到 HTTP 调用区分大小写。 Now I have added a bunch of if statements to handle the different variations haha.现在我添加了一堆 if 语句来处理不同的变化哈哈。 Thanks for reading.谢谢阅读。

Judging by the naming convention you are on an older version of SharePoint.根据命名约定判断您使用的是旧版 SharePoint。 The x0020 is the value for a space. x0020是空格的值。 Ideally when you first create the column you would name it without the spacing.理想情况下,当您第一次创建列时,您可以不带间距地命名它。 For example UserInformation.例如用户信息。 Then come in and edit the name after the fact and call it User Information.然后进来并在事后编辑名称并将其称为用户信息。 If you click on the title name and look at the URL, you will see what the actual name of the column is at the end of the URL.如果单击标题名称并查看 URL,您将在 URL 末尾看到列的实际名称。 It is case sensitive because you can have a column named score and Score which is ultimately why it wasn't working.它区分大小写,因为您可以有一个名为 score 和 Score 的列,这最终是它不起作用的原因。

Must load all fields like this必须像这样加载所有字段

 var lists = context.Web.Lists;
            context.Load(lists);
            context.ExecuteQuery();

            CamlQuery query = new CamlQuery();
            query.ViewXml = @"";

            var list = lists.GetById("file.guid");
            var listitems = list.GetItems(query);
            context.Load(listitems);
            context.ExecuteQuery();

            var creationInformation = new ListItemCreationInformation();
            var newItem=list.AddItem(creationInformation);

            var fields = list.Fields;
            context.Load(fields);
            context.ExecuteQuery();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM