次の方法で共有


Sharepoint 2016 : REST API Calls fail with error Column doesnot exists

Symptom : Rest API call fails when first character of column starts with underscore “_” https://sp2016/_api/web/lists/getbytitle('Documents')/items/?$select=_Enddate

Using Internet explorer , we can see the response as 400 Bad request

 

 

 

 

 

 

 

 

 

 

 

 

You may see a different error message when the same URL is accessed using a non-IE browser.

eg:

 

 

 

 

 

 

 

 

 

The corresponding SharePoint ULS shows the following stack

Exception occured in scope Microsoft.SharePoint.SPListItemEntityCollection ._SerializeToOData. Exception=Microsoft.SharePoint.SPException: Column '_EndDate' does not exist. It may have been deleted by another user.at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetFieldRef(XmlWriter writer, String fieldPath, FieldRefUsage fieldRefUsage, Action`1 attributeAction)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilderUtilities.SetWhereBinaryOp[T](XmlWriter writer, EdmParserNode parseNode, SetFieldRefDelegate`1 setFieldRef, SetValueDelegate`1 setValue, GetConvertedValueDelegate getConvertedValue)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilderUtilities.SetWhereInternal[T](XmlWriter writer, EdmParserNode parseNode, SetFieldRefDelegate`1 setFieldRef, SetValueDelegate`1 setValue, GetConvertedValueDelegate getConvertedValue)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilderUtilities.SetWhereBinaryOp[T](XmlWriter writer, EdmParserNode parseNode, SetFieldRefDelegate`1 setFieldRef, SetValueDelegate`1 setValue, GetConvertedValueDelegate getConvertedValue)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilderUtilities.SetWhereInternal[T](XmlWriter writer, EdmParserNode parseNode, SetFieldRefDelegate`1 setFieldRef, SetValueDelegate`1 setValue, GetConvertedValueDelegate getConvertedValue)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilderUtilities.SetWhere[T](XmlWriter writer, EdmParserNode parseNode, SetFieldRefDelegate`1 setFieldRef, SetValueDelegate`1 setValue, GetConvertedValueDelegate getConvertedValue)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetViewQuery(SPQuery query, XmlWriter writer, StringBuilder sb)at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.BuildCamlQuery()at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder..ctor(SPList list, RESTfulQuery restQuery, Nullable`1 itemId)at Microsoft.SharePoint.SPListItemEntityCollectionQuery..ctor(SPList list, RESTfulQuery restQuery, Nullable`1 itemId)at Microsoft.SharePoint.SPListItemEntityCollection.TryWriteAsOData(ServerStub serverStub, ODataWriter writer, RESTfulQuery query, ProxyContext proxyContext)at Microsoft.SharePoint.Client.ServerStub.Write(Object value, Uri path, ODataWriter writer, RESTfulQuery query, ProxyContext proxyContext)

 

Cause /Reason:

This is a limitation of OData protocol which does not allow “_” to be the first character. Therefore, SharePoint prefixes OData_ to the internal name, if the field name starts with an underscore and workaround is to do the same manually in our rest api query.

Workaround:

Prefix OData_ manually in the rest api query

The sample query will look like following https://sp2016/_api/web/lists/getbytitle('Documents')/items/?$select=OData__Enddate

Note: There are 2 underscores in above query OData__Enddate

 

 

 

 

 

 

 

 

 

 

 

 

 

Note : Some of the OOB columns which starts with underscore and rest call to them fails

_DCDateModified
_Author
_dlc_Exempt
_Level
_Enddate
_UIVersionString
_vti_ItemDeclaredRecord
_dlc_DocId
_EditMenuTableStart2
_UIVersion
_Status
_dlc_DocIdUrl
_EndDate
_Relation
_Identifier
_HasCopyDestinations
_CopySource
_ResourceType
_CheckinComment
_Contributor
_dlc_DocIdPersistId
_dlc_ExpireDateSaved
_Revision
_SourceUrl
_Photo
_Publisher
_Version
_EditMenuTableStart
_Coverage
_Comments
_LastPrinted
_vti_ItemHoldRecordStatus
_RightsManagement
_Category
_Source
_Format
_dlc_ExpireDate
_DCDateCreated
_vti_ItemIsLocked
_IsCurrentVersion
_SharedFileIndex
_ModerationComments
_ModerationStatus
_EditMenuTableEnd

 

POST By : Brijesh Poddar [MSFT]