Skip to content

Pre-request and post-request for api request #557

Open
0 of 1 issue completed
Open
Feature
0 of 1 issue completed
@WrathOP

Description

@WrathOP

Add Pre/Post Request Scripts to APIDash

Why We Need This

I've been using APIDash for my API testing, and it's great! However, I often find myself manually adding auth tokens or transforming data for each request. This gets tedious, especially when working with authenticated APIs or when I need to chain multiple requests together.

What I'm Looking For

I'd love to see something similar to Postman's pre-request and test scripts in APIDash. The idea is to have a simple code editor where we can write JavaScript that runs before and after our requests. This would help with:

  • Adding auth tokens automatically (no more copy-pasting!)
  • Setting up environment variables through code
  • Transforming request/response data on the fly
  • Chaining API calls (like when you need to get a token first)
  • Basic testing and validation

Example Use Cases

  1. Auth Token Management

    // Pre-request: Add token to headers
    request.headers['Authorization'] = `Bearer ${env.get('AUTH_TOKEN')}`;
  2. Dynamic Variables

    // Set an env variable based on response
    env.set('USER_ID', response.body.id);
  3. Request Chaining

    // Get fresh token if expired
    if (response.status === 401) {
      // Refresh token logic here
      env.set('AUTH_TOKEN', newToken);
    }

Why This Would Be Awesome

  • Saves time on repetitive tasks
  • Makes working with auth much easier
  • Helps automate testing flows
  • Great for complex API workflows

I personally use these features a lot in Postman, and having them in APIDash would make it even better for my daily API development work. Would love to help test this if it gets implemented!

Technical Notes

  • Need a way to access/modify environment variables
  • Should be able to modify request/response data
  • Basic console for debugging would be helpful

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions