This C# console application sends parallel HTTP POST requests to an API endpoint to retrieve job status information and saves each response to disk.
Each job runs in its own worker loop and continuously polls the API at a configurable interval.
The application is intended for high-frequency polling, storing every response with a timestamp for troubleshooting, auditing, or analysis.
- Parallel workers (one per job)
- HTTP Basic Authentication
- Continuous polling loop
- Configurable request delay
- Automatic output folder creation
- JSON pretty-printing (falls back to raw text if response is not JSON)
- Timestamped response files
- A list of job names is defined.
- One worker task is created per job.
- Each worker repeatedly:
- Sends a POST request with
{ "JobName": "<job>" } - Reads the response
- Formats JSON if possible
- Saves the response to a job-specific folder
- Sends a POST request with
- The application runs continuously until manually stopped.
Update these values in the source code:
private static readonly string username = "MyUser";
private static readonly string password = "MyPass";
private static readonly string url = "http://localhost:8181/api.rsc/getJobStatus";Define the list of jobs that will be polled in parallel.
Each job runs in its own worker loop and sends requests independently.
private static String[] listOfJobNames = new string[] {
"j1",
"j2",
"j3",
"j4",
"j5",
"j6"
};Specify the base directory where all job response files will be written.
private static readonly string outputFolderPath = "C:\\MyOutputFolder\\";Example structure:
C:\MyOutputFolder\
├── j1\
│ ├── resp_20240101_120000_123.json
├── j2\
├── j3\Controls the delay between consecutive API requests for each worker.
private static readonly int delayMs = 1;