0

I am trying to do a post request via graph in a webpart - it keeps returning either fetch failed or 403. Can anyone please point in either a sample post request or how to fix

Ive confirmed via graph exploper that the api and post properties are correct and work. Just when I put in the webpart it fails :-(

this.props.context.msGraphClientFactory
      .getClient()
      .then((client: MSGraphClient): void => {
        client         
         .api("sites/MYSITEID/lists/MYLISTID/items")
         .version("v1.0")
          .post(MYFIELDS, (err, res, success) => {
            if (err) {  
                   console.error(err);  
              return;  
            }                
            if (success)
            {
              console.log("success");
            }
                  alert('Added');
          })//closes
      });

1 Answer 1

0

You have to add this to package-solution.json.

Example: When sending a mail,

"webApiPermissionRequests": [
      {
        "resource": "Microsoft Graph",
        "scope": "Mail.Send"
      }
    ]

And in the admin portal (API Management) it needs an approval (to use Graph Api).

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.