SharePoint odata POST succeeds using IE, fails using Chrome

Oct 1, 2012 at 1:20 PM

Hello,

I use datajs with the SharePoint 2010 odata service. I can successfully insert a new item in a list using Internet Explorer, but using Chrome the response is always HTTP 500, yet the item has been inserted anyway.  WTF??? Using Fiddler I can see the request headers are slightly different between IE and Chrome, but the JSON request body is the same. Here is the IE request:

POST http://win-9dscbb9bq8k/_vti_bin/listdata.svc/Risks HTTP/1.1
Content-Type: application/json;odata=verbose
Accept-Language: en-gb
dataserviceversion: 1.0
Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1
maxdataserviceversion: 2.0
Referer: http://win-9dscbb9bq8k/_Layouts/RiskManagement/Risk.aspx
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Host: win-9dscbb9bq8k
Content-Length: 360
Connection: Keep-Alive
Pragma: no-cache
Authorization: Negotiate oXcwdaADCgEBoloEWE5UTE1TU1AAAwAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAAAAAAABYAAAAAAAAAFgAAAAAAAAAWAAAABXCiOIGAbEdAAAAD36Ifnd+nJo7ac3egkJon4yjEgQQAQAAAPUXp1AtIpqEAAAAAA==

{"Title":"bla","AssetId":1,"DepartmentId":6,"Description":"","AssetManagementPlanValue":"None","RiskMatrixId":1,"SeverityId":1,"LikelihoodId":1,"RatingId":1,"ColourValue":"None","CurrentMitigationInPlace":"","AdditionalMitigationRequired":"","DecisionRequired":"","AssignedToId":null,"OwnerId":null,"StatusValue":"Open","Completed":null,"DirectionValue":"New"}

and here is the Chrome request:

POST http://win-9dscbb9bq8k/_vti_bin/listdata.svc/Risks HTTP/1.1
Host: win-9dscbb9bq8k
Connection: keep-alive
Content-Length: 360
Origin: http://win-9dscbb9bq8k
MaxDataServiceVersion: 2.0
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4
Content-Type: application/json;odata=verbose
Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1
DataServiceVersion: 1.0
Referer: http://win-9dscbb9bq8k/_Layouts/RiskManagement/Risk.aspx
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

{"Title":"bla","AssetId":1,"DepartmentId":6,"Description":"","AssetManagementPlanValue":"None","RiskMatrixId":1,"SeverityId":1,"LikelihoodId":1,"RatingId":1,"ColourValue":"None","CurrentMitigationInPlace":"","AdditionalMitigationRequired":"","DecisionRequired":"","AssignedToId":null,"OwnerId":null,"StatusValue":"Open","Completed":null,"DirectionValue":"New"}

This is the response I get using Chrome:

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Content-Type: application/json
Server: Microsoft-IIS/7.5
SPRequestGuid: 502f2cb1-ec9f-49d0-b316-42a2ef6aeed6
X-SharePointHealthScore: 0
DataServiceVersion: 1.0;
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 14.0.0.6120
X-MS-InvokeApp: 1; RequireReadOnly
Date: Mon, 01 Oct 2012 13:14:24 GMT
Content-Length: 2254

{
"error": {
"code": "", "message": {
"lang": "en-GB", "value": "An error occurred while processing this request."
}, "innererror": {
"message": "Value does not fall within the expected range.", "type": "System.ArgumentException", "stacktrace": "   at Microsoft.SharePoint.SPFieldMap.GetColumnNumber(String strFieldName, Boolean bThrow)\r\n   at Microsoft.SharePoint.SPListItemCollection.GetColumnNumber(String groupName, Boolean bThrowException)\r\n   at Microsoft.SharePoint.SPListItemCollection.GetRawValue(String fieldname, Int32 iIndex, Boolean bThrow)\r\n   at Microsoft.SharePoint.SPListItem.GetValue(SPField fld, Int32 columnNumber, Boolean bRaw, Boolean bThrowException)\r\n   at Microsoft.SharePoint.SPListItem.GetValue(String strName, Boolean bThrowException)\r\n   at Microsoft.SharePoint.SPListItem.get_Item(String fieldName)\r\n   at Microsoft.SharePoint.Linq.PropertyMap.GetSPFieldValue(PropertyMap pm, SPListItem item, JoinPath joinPath)\r\n   at Microsoft.SharePoint.Linq.PropertyMap.b__3(DataContext dc, SPListItem item, Object entity, JoinPath joinPath)\r\n   at Microsoft.SharePoint.Linq.PropertyMap.GetFromListItem(DataContext dc, SPListItem item, Object entity, JoinPath joinPath)\r\n   at Microsoft.SharePoint.Linq.EntityRef.RefreshEntityWithListItem()\r\n   at Microsoft.SharePoint.Linq.EntityTracker.AddItem(EntityRef eref, ITrackOriginalValues origVals)\r\n   at Microsoft.SharePoint.Linq.EntityTracker.SubmitNewEntity(NewEntityRef newEref, Stack`1 visited)\r\n   at Microsoft.SharePoint.Linq.EntityTracker.SubmitNewEntities()\r\n   at Microsoft.SharePoint.Linq.EntityTracker.SubmitChanges(ConflictMode failureMode, Boolean systemUpdate)\r\n   at Microsoft.SharePoint.Linq.DataContext.SubmitChanges(ConflictMode failureMode, Boolean systemUpdate)\r\n   at Microsoft.SharePoint.Linq.DataContext.SubmitChanges(ConflictMode failureMode)\r\n   at Microsoft.SharePoint.Linq.DataContext.SubmitChanges()\r\n   at Microsoft.SharePoint.Linq.DataServiceDataContext.SaveChanges()\r\n   at System.Data.Services.UpdatableWrapper.SaveChanges()\r\n   at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)\r\n   at System.Data.Services.DataService`1.HandleRequest()"
}
}
}

As I said above, despite the error, the new item was successfully inserted into the SharePoint list. Why does IE get a HTTP 201 Created response and why does Chrome get the HTTP 500 Internal server error response?

 

Oct 2, 2012 at 4:57 PM
Edited Oct 2, 2012 at 6:09 PM

Hi Remco,

   I'm not very knowledgeable of Sharepoint.. so you might want to pursue the root cause of this issue to them.  However thi is what I think... I noticed the the request you are sending with Chrome doesn't have Authorization header nor security token like the one sent from IE.  This is causing the Chrome request to be less privileged than the one made from IE (assuming the user logged on in IE would be an admin or some how have some higher privileges).   I think you are seeing the exception becasue of Sharepoint defaults as explained here:

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/13e10e5a-acd6-4a9f-a45f-b05b4fd61045

Regards,

Alex Trigo.

Oct 3, 2012 at 8:50 AM
Edited Oct 3, 2012 at 9:35 AM

Hi Alex,

Thank you very much. That solved the problem. My SharePoint list has 10 lookup columns and the default threshold is 8. Very strange that Chrome does not authenticate the same way as IE does. This is not just a problem with odata but also with the normal web interface of SharePoint. When you browse to the SharePoint list in Chrome SharePoint tells you :

This view cannot be displayed because the number of lookup and workflow status columns it contains exceeds the threshold (8) enforced by the administrator.

With IE you get to see the list ok.

I increased the threshold and now it works in Chrome too. It is very strange though to get an error from the odata service when the insert was committed anyway. I ended up with duplicate records as I retried the insert again and again.

thanks for your help

Remco