A powerful plugin for ScriptRunner designed to simplify RESTful API integrations. This plugin leverages RestSharp to enable seamless interaction with REST APIs, supporting dynamic authentication, flexible configurations, and easy-to-use methods for common HTTP operations.
- Dynamic Base URL Management: Easily configure base URLs for different APIs.
- Built-in Authentication: Includes support for Basic, Bearer token, and OAuth2 authentications.
- Extensibility: Supports registration of custom authentication strategies.
- Ease of Use: Simplified methods for common HTTP operations:
GET
,POST
,PUT
, andDELETE
. - ScriptRunner Integration: Fully integrated into the ScriptRunner ecosystem.
Place the ScriptRunner.Plugins.RestEase
plugin assembly in the Plugins
folder of your ScriptRunner project. The plugin will be automatically discovered and activated.
Here’s an example script for fetching cryptocurrency market data from the CoinGecko API:
/*
{
"TaskCategory": "Networking",
"TaskName": "Fetch Cryptocurrency Market Data",
"TaskDetail": "This script fetches cryptocurrency market data from CoinGecko."
}
*/
var restEase = PluginLoader.GetPlugin<ScriptRunner.Plugins.RestEase.IRestEase>();
restEase.SetBaseUrl("https://api.coingecko.com/api/v3");
var queryParams = new
{
vs_currency = "usd",
ids = "bitcoin,ethereum",
order = "market_cap_desc",
per_page = 10,
page = 1,
sparkline = false
};
var queryString = string.Join("&", queryParams.GetType().GetProperties()
.Select(p => $"{p.Name}={Uri.EscapeDataString(p.GetValue(queryParams)?.ToString() ?? string.Empty)}"));
var response = await restEase.GetAsync($"/coins/markets?{queryString}");
Dump(response.Content.ReformatJson());
return "Cryptocurrency data fetched successfully.";
var configuration = new Dictionary<string, object>
{
{ "DefaultTimeout", 30 } // Timeout in seconds
};
var restEase = PluginLoader.GetPlugin<ScriptRunner.Plugins.RestEase.IRestEase>();
restEase.Initialize(configuration);
Set the authentication for your requests:
restEase.SetAuthentication("bearer", "your-bearer-token");
Supported authentication types:
- none: No authentication
- basic: Username and password as
(username, password)
- bearer: Bearer token
- oauth2: OAuth2 with
(tokenUrl, clientId, clientSecret, scope)
Register a custom authenticator within your script or plugin:
restEase.RegisterAuthenticator("customAuth", options => new CustomAuthenticator(options));
restEase.SetAuthentication("customAuth", customOptions);
- Use tools like Postman to validate the endpoints before scripting.
- Test end-to-end workflows within ScriptRunner using this plugin for your API tasks.
This plugin is licensed under the MIT License.
- Fork this repository.
- Create a feature branch (
git checkout -b feature/YourFeature
). - Commit your changes (
git commit -m 'Add YourFeature'
). - Push the branch (
git push origin feature/YourFeature
). - Open a pull request.
Developed with 🧡 passion by Peter van de Pas.
For any questions or feedback, feel free to open an issue or contact me directly!
This project is licensed under the MIT License.