Azure / Office 365 / SharePoint Development / Search

Perform other types of HTTP requests with HttpClient and SPHttpClient in SPFx projects

on May 18, 2017 by Elio Struyf with no comments

If you already used the HttpClient and SPHttpClient in your SharePoint Framework projects, you might have noticed that you have two types of request methods options: GET and POST. These two types of requests are the most used ones, but what if you want to use other HTTP methods like PUT, PATCH, DELETE?

If you need to make calls with other HTTP methods, you can make use of the fetch which is available on both the HttpClient and SPHttpClient classes. The fetch method allows you to specify the HTTP method type per request yourself. Fetch is also used behind the scenes when you are using the GET and POST methods.

Here is an example of how you can make use of the fetch method and specifying the request method to perform:

Here is an example with the HttpClient, but you will notice that is not that different to use:


Article comments