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 Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

Leave a Reply

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