Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

REST create list item with Person field that allows multiple names

$
0
0

Can anyone please advise: we are using REST to create list items and have done several of these. This is the first time we are attempting to create a list item with a Person or Group field that allows multiple names. I understand the field expects Collection(Edm.Int32) so we created an object with the IDs of all the users. Passing this in, however, continues to give us the error:

A node of type 'StartArray' was read from the JSON reader when trying to read a value of a property; however, a 'PrimitiveValue' or 'StartObject' node was expected.

Our jQuery function that creates is below.  We use the same one for forms with single Person fields without issue.

function createSPListItem(url, listName, itemFlds, success, failure) {
    try {
        var postURL = url + "/_api/web/lists/getbytitle('" + listName + "')/items";


        $.ajax({
            url: postURL,
            type: "POST",
            contentType: "application/json;odata=verbose",
            data: JSON.stringify(itemFlds),
            headers: {"Accept": "application/json;odata=verbose","X-RequestDigest": $("#__REQUESTDIGEST").val()
            },
            success: function (data) {
                success(data);
            },
            error: function (data) {
                failure(data);
            }
        });
    } catch (err) {
        formError(arguments.callee, err.toString());
    }
}

Our Payload looks like:

{"__metadata":{"type":"SP.Data.OurListItem"},"RequestorId": [106,111],"Title":"pn","Phone_x0020_Extension":"25283","DirectorId":1,"Project_x0020_Details":"pn","ContinueWith":"i","CompleteDate":"03/09/2016","AssignedToId":null,"Phase":"New","Status":"Green"}


- Thank you. Respectfully, Janette M. Ricker


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>