Microsoft 365 – SharePoint online – SPFx – resolving error – Error making HttpClient request in queryable [400] – Microsoft.SharePoint.Client.InvalidClientQueryException – PrimitiveValue or StartObject node was expected – while updating multivalue person field through SPFx component

Microsoft 365 - SharePoint online - SPFx - resolving error - Error making HttpClient request in queryable [400] - Microsoft.SharePoint.Client.InvalidClientQueryException - PrimitiveValue or StartObject node was expected - while updating multivalue person field through SPFx component
Microsoft 365 - SharePoint online - SPFx - resolving error - Error making HttpClient request in queryable [400] - Microsoft.SharePoint.Client.InvalidClientQueryException - PrimitiveValue or StartObject node was expected - while updating multivalue person field through SPFx component

Hi All,

Greetings for the day!!! Today new issue and solution πŸ™‚

Background / Details

  • I am implementing one simple small SPFx component
  • SPFx component –
    • Reading / getting some details from users and storing in SharePoint online list
    • In our SharePoint online list we have one multivalued person / user column along with Title and Desc fields
    • On save button click we are submitting details to our SharePoint online list
  • Following is the code which we are using to add the item in list

private async SaveData() :Promise<void> {
   
    const web = Web("https://knowledgejunction1.sharepoint.com/sites/demo");

    await web.lists.getByTitle("listtitle").items.add({
      Title:this.state.title,
      ownerId: this.state.owneremail,
      desc: this.state.desc
    }).then(() => {
      //console.log(i);
    });
    alert("Request submitted successfully.");
  }

  • While submitting details through SharePoint list we were getting an error

Error / Issue

Uncaught (in promise) 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.”}}}
at new HttpRequestError (parsers.js:130:1)
at Function. (parsers.js:145:1)
at step (tslib.es6.js:102:1)
at Object.next (tslib.es6.js:83:45)
at fulfilled (tslib.es6.js:73:42)

Microsoft 365 - SharePoint online - SPFx - resolving error - Error making HttpClient request in queryable [400] - Microsoft.SharePoint.Client.InvalidClientQueryException - PrimitiveValue or StartObject node was expected - while updating multivalue person field through SPFx component
Microsoft 365 – SharePoint online – SPFx – resolving error – Error making HttpClient request in queryable [400] – Microsoft.SharePoint.Client.InvalidClientQueryException – PrimitiveValue or StartObject node was expected – while updating multivalue person field through SPFx component

Solution / Root cause

  • This error was occuring because the way we are assigning the values from our multivalued person column to the list column in SaveData() as

ownerId: this.state.owneremail

  • Actually we need to assign the value as an object as

ownerId: {results: this.state.owneremail}

  • Complete method
private async SaveData() :Promise<void> {
   
    const web = Web("https://knowledgejunction1.sharepoint.com/sites/demo");

    await web.lists.getByTitle("listtitle").items.add({
      Title:this.state.title,
      ownerId: {results: this.state.owneremail},
      desc: this.state.desc
    }).then(() => {
      //console.log(i);
    });
    alert("Request submitted successfully.");
  }

REFERENCES

Thanks for reading!!! HAVE a FANTASTIC LEARNING AHEAD πŸ™‚ LIFE IS BEAUTIFUL πŸ™‚

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: