0

In my spfx webpart, I'm creating list item using pnp js. As per pnp-core-js documentation I have written following code, but its failing with error.

Private AddListItem()
{
    pnp.sp.web.lists.getByTitle('EmployeeList').items.add({
    JobTitle : this.state.var_JobTitle,
    JobDescription :this.state.var_JobDescription,
    Salary:this.state.var_Salary,
    Age:this.state.var_Age,
    LocationId:this.state.var_Location.key,
    Technology:this.state.var_Technology.key,
    Passport:this.state.var_Passport,
    ManagerId:{results:[15,29]}
    }).then((iar:pnp.ItemAddResult)=> {
    console.log(iar);
    });
}

Error:

Error: Error making HttpClient request in queryable [400]  ::> {"odata.error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"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."}}}

NOTE: If I comment that line (ManagerId) then code works fine.

  • are you using the correct internal name of the column ? Also, have you set the column to allow multiple values ? – Gautam Sheth Jan 29 at 10:54
2

Code looks fine.

1) Just ensure that you are using the correct internal name of the column.

2) Secondly, ensure that you have set the column to Allow multiple values as below. This error usually occurs when you try to update the column when this setting not present and only allows a single user value :

enter image description here

  • Its my bad. Internal name is right but multi selection was not selected, thats why. Thanks. – SP Developer Jan 29 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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