When working with certain endpoints, we sometimes need to pass additional information in requests, such as authorization credentials, cache control instructions, API version information, and more.
This information is usually taken from HTTP request headers. In this article, we will show you how to add custom HTTP headers to ShortPoint connections.
This feature is currently available in the following ShortPoint connection types:
- REST API
- Site News
- Org News
- Hub News
- Current Site
- Other Site
- Site URL
- People Search
- RSS Feeds
- Web Service XML
Prerequisites
- You have the latest ShortPoint SPFx version installed on your SharePoint site.
- You are a ShortPoint Designer with an active license.
Adding custom HTTP headers
To add custom HTTP headers to your connection, follow these steps:
Step 1: Set up your connection
- In the Design Element settings, open the Connect tab.
- Select a connection type.
- Ensure that all the required fields are completed to establish a successful connection.
In our example, we are using the REST API connection type, and all we need to do is enter the URL.
Step 2: Enable Advanced Settings
- Scroll down and look for the Enable Advanced Settings toggle. Switch it on.
Step 3: Input your custom headers
- In the Custom headers field and input your values.
If, for example, you want to force caches to submit the request to the origin server for validation before releasing a cached copy, you need to add a Cache-Control header with the value no-cache to the HTTP request.
headers["<Header name>"] = <Header value>
In that case, we will enter the following:
headers["Cache-Control"] = "no-cache";
return headers;
Note: Headers object can accept as many headers as you want and all of them will be added to the HTTP request.
Step 4: Hit Connect
- Once done, click the Connect button.
You can now proceed to select the data you want to display in the Items tab and update your Design Element.
That is how simple adding custom headers is in ShortPoint connections. Give it a try!
Related articles: