In this post, let's see how to make an HTTP POST request from an SharePoint Framework (SPFx) web part. There are lots of posts out already which show you how to make a GET request so I will not cover that here. It is fairly straightforward once you understand all the moving parts.
Import the necessary modules in your SPFx webpart code:
Now, the code which makes a POST request to create a list:
And my "Developer workbench" list is created:
Hope this helps.
Hi Vardhaman, When I try to use the code. I receive CORS exception in IE for REST api ? Did you get into these issues
It seems to work fine for me on IE11. Are you trying to make a request to a different domain?
Its working Fine. But not able to edit or update the list items.
Hi Vardhaman, we are trying to do OData Post query from One Site collection to another Site collection.it gives me Cross site Scripting Error but both Site collection in Same Domain.is it expected result or doing something wrong.
It seems to be working fine for me. Here is the code I am using to create a list item in another site collection on the same domain:
Post a Comment