Add headers to REST module automatically

Hi everyone.

I have an application that needs three key/value pairs to be added to each REST API call:

x-app-system-id
x-app-client-id
x-app-client-secret

Naturally I do not want to hardcode this info into every REST module used in all my scenarios, so I’m looking for a better way.

In Postman, for example, you can define a Pre-Request Script which will execute before each REST execution in a collection, such as:

pm.request.headers.add({
key: “x-app-system-id”,
value: “93845453325928”
});
pm.request.headers.add({
key: “x-app-client-id”,
value: “xxxxxxxxx-1d57-4943-b705-e0dg45h3h4a0d34”
});
pm.request.headers.add({
key: “x-app-client-secret”,
value: “xxxxxxxxx-7cce-4ae5-b59b-4a1grybhe7e43f7ab7”
});

Questions:

  1. Is there a similar method to do this in Make, where headers can automatically be created for each REST module used in a scenario?
  2. If not, can I at a minimum do a variable substitution of the values in each header so I do not hard-code them inside each REST module used?

Cheers,

Dennis.

Welcome to the Make community!

You can create a custom app, or

Use a Custom variable to store the three headers, available only on Pro, Teams, and Enterprise plans.

Screenshot_2024-04-04_220445

Alternatively, if you are on Enterprise, you can use a Custom Function to insert the three headers.

2 Likes

Thanks for your quick response!

I am on a legacy subscription so can’t do the custom variables or custom function unfortunately, but I can create a custom app.

The only thing is, that process seems to be quite difficult for me even though I only want to add headers to a REST GET or PUT…

I’ve perused the documentation and created an app and the following base:

{
	"baseUrl": "https://api.app.com/pw/api/rest/v1",
	"headers": [
		{
			"Content-Type": "application/json",
			"x-app-system-id": "xxxxxxxx",
			"x-app-client-id": "xxxxxxxx",
			"x-app-client-secret": "xxxxxxxx"
		}
	]
}

I then created a module “GET APP API” with Action = Read and the following values:

Communication:

{
    "url": "/"
}

Static Parameters,Mappable Parameters, and Interface:

[
]

I then set the Module as Visible and Published.

In a new scenario, I can see the module, but when trying to edit it it just shows a box saying User ID and that’s all. I want it to look exactly like the HTTP Make a Basic Auth Request - how can I do this?

This is going into Custom Apps territory, your new question might be better answered there.

2 Likes