Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a custom list and added a multi-value user field (no groups) called AssignedTo to the list's definition. Using the SharePoint interface I added an item with a value for Title and AssignedTo (I put two users into the AssignedTo field).

I have tried adding a third user, deleting one of the current users, and completely nulling the field's value using the REST API (ListData.svc). Regardless of what I do I receive an error.

Request Headers:

Request:    POST /_Layouts/_vti_bin/listdata.svc/TestList(1) HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
If-Match:   W/"3"
X-HTTP-Method:  MERGE
X-Requested-With:   XMLHttpRequest
Referer:    http://dev-02/_Layouts/PAR/peoplepicker.aspx
Accept-Language:    en-us
Accept-Encoding:    gzip, deflate
Content-Length: 1128
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Host:   dev-02
Cookie: WSS_KeepSessionAuthenticated={535c3f2a-f7de-4a31-8a43-f7fa5a0e57e3}; Ribbon.ListItem=944977|-1|281|911837184; Ribbon.ListForm.Edit=620323|-1|272|-1226667017; Ribbon.Permission=944977|-1|451|-1941869242; Ribbon.List=944977|9|33|911837184
Connection: Keep-Alive
Cache-Control:  no-cache
Content-Type:   application/json

Payload:

{
    "Id": 1,
    "Title": "Some stuff that does not work?",
    "AssignedTo": {
        "results": [
            {
                "__metadata": {
                    "uri": "http://dev-02/_vti_bin/listdata.svc/UserInformationList(5)",
                    "etag": "W/\"1\"",
                    "type": "Microsoft.SharePoint.DataService.UserInformationListItem"
                },
                "Id": 5,
                "ContentTypeID": "0x010A00F0F0729F7F61C84E91A87204A17DF669",
                "ContentType": "Person",
                "Name": "Jason Young",
                "Modified": "/Date(1362402512000)/",
                "Created": "/Date(1362402512000)/",
                "CreatedBy": {
                    "__deferred": {
                        "uri": "http://dev-02/_vti_bin/listdata.svc/UserInformationList(5)/CreatedBy"
                    }
                },
                "CreatedById": 1073741823,
                "ModifiedBy": {
                    "__deferred": {
                        "uri": "http://dev-02/_vti_bin/listdata.svc/UserInformationList(5)/ModifiedBy"
                    }
                },
                "ModifiedById": 1073741823,
                "Owshiddenversion": 1,
                "Version": "1.0",
                "Attachments": {
                    "__deferred": {
                        "uri": "http://dev-02/_vti_bin/listdata.svc/UserInformationList(5)/Attachments"
                    }
                },
                "Path": "/_catalogs/users",
                "Account": "DOM\\jyoung",
                "EMail": "Jason.Young@domain.com",
                "MobileNumber": null,
                "AboutMe": null,
                "SIPAddress": "Jason.Young@domain.com",
                "IsSiteAdmin": false,
                "Deleted": false,
                "Picture": null,
                "Department": "IT",
                "JobTitle": "Electronic Engineer"
            }
        ]
    }
}

Response Headers:

Response    HTTP/1.1 400 Bad Request
Cache-Control   private
Content-Type    application/json
Server  Microsoft-IIS/7.5
SPRequestGuid   3911096c-a7da-4571-80fe-f00ac79bcecb
Set-Cookie  WSS_KeepSessionAuthenticated={535c3f2a-f7de-4a31-8a43-f7fa5a0e57e3}; path=/
X-SharePointHealthScore 1
DataServiceVersion  1.0;
X-AspNet-Version    2.0.50727
Persistent-Auth true
X-Powered-By    ASP.NET
MicrosoftSharePointTeamServices 14.0.0.6029
Date    Thu, 11 Apr 2013 21:11:24 GMT
Content-Length  175

Response Body:

{
    "error": {
        "code": "",
        "message": {
            "lang": "en-US",
            "value": "Error processing request stream. The payload must represent a valid array format for collections."
        }
    }
}
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

To remove one user from the multi-valued lookup you send a delete to http://dev-02/_vti_bin/listdata.svc/TestList(1)/$links/AssignedTo(5) where 5 represents the ID of the user you wish to remove from the lookup field.

If you want to add a user to the multi-valued field you send a post to http://dev-02/_vti_bin/listdata.svc/TestList(1)/AssignedTo with the X-HTTTP_method: MERGE header and the following payload:

 {
        "__metadata": {
            "uri": "http://dev-02/_vti_bin/listdata.svc/UserInformationList(14)",
            "etag": "W/\"1\"",
            "type": "Microsoft.SharePoint.DataService.UserInformationListItem"
        }
}

Where 14 is the ID (in the UserInformationList) of the user you wish to add to the field. This exact methodology will work with other lookup fields as well.

WARNING: If you send a DELETE to an URL and do not specify $links in the URL as shown above you will delete the associated list item NOT JUST the relationship. This generates a 500 server error if it is a user value.

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code></code>
<message xml:lang="en-US">An error occurred while processing this request.</message>
<innererror>
<message>Cannot complete this action.

Please try again.</message>
<type>Microsoft.SharePoint.SPException</type>
<stacktrace>at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)&#xD;
   at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid&amp; pgDeleteTransactionId)&#xD;
   at Microsoft.SharePoint.SPListItem.DeleteCore(DeleteOp deleteOp)&#xD;
   at Microsoft.SharePoint.SPListItem.Delete()&#xD;
   at Microsoft.SharePoint.Linq.EntityTracker.Delete(SPListItem item)&#xD;
   at Microsoft.SharePoint.Linq.EntityTracker.SubmitDeletedEntities()&#xD;
   at Microsoft.SharePoint.Linq.EntityTracker.SubmitChanges(ConflictMode failureMode, Boolean systemUpdate)&#xD;
   at Microsoft.SharePoint.Linq.DataContext.SubmitChanges(ConflictMode failureMode, Boolean systemUpdate)&#xD;
   at Microsoft.SharePoint.Linq.DataContext.SubmitChanges()&#xD;
   at Microsoft.SharePoint.Linq.DataServiceDataContext.SaveChanges()&#xD;
   at System.Data.Services.UpdatableWrapper.SaveChanges()&#xD;
   at System.Data.Services.DataService`1.HandleNonBatchRequest(RequestDescription description)&#xD;
   at System.Data.Services.DataService`1.HandleRequest()</stacktrace>
<internalexception>
<message>Cannot complete this action.

Please try again.&lt;nativehr&gt;0x80004005&lt;/nativehr&gt;&lt;nativestack&gt;&lt;/nativestack&gt;</message>
<type>System.Runtime.InteropServices.COMException</type>
<stacktrace>at Microsoft.SharePoint.Library.SPRequestInternalClass.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid&amp; pgDeleteTransactionId)&#xD;
   at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid&amp; pgDeleteTransactionId)</stacktrace>
</internalexception>
</innererror>

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.