Batch Requests


PI Web API Basics.

Efficient data retrieval with batch operations



Challenges

Simple Batch Request

Batch requests allow multiple API calls in a single HTTP request.

Objective

Create a batch request that queries two points simultaneously.

Request Format

POST a JSON object with named requests to /piwebapi/batch

Example

curl -X POST http://challenge/piwebapi/batch \
  -H "Content-Type: application/json" \
  -d '{"point1": {"Method": "GET", "Resource": "/piwebapi/points/P1DP700"}, "point2": {"Method": "GET", "Resource": "/piwebapi/points/P1DP701"}}'

Connect with SSH

Link your SSH key, then connect with: ssh hacker@dojo.idg.ctf

Parallel Batch Requests

Execute multiple independent requests in parallel for better performance.

Objective

Create a batch with 3 parallel value queries using the ParentIds field.

Requests without ParentIds run in parallel.

Example

curl -X POST http://challenge/piwebapi/batch \
  -H "Content-Type: application/json" \
  -d '{
    "v1": {"Method": "GET", "Resource": "/piwebapi/streams/P1DP800/value"},
    "v2": {"Method": "GET", "Resource": "/piwebapi/streams/P1DP801/value"},
    "v3": {"Method": "GET", "Resource": "/piwebapi/streams/P1DP802/value"}
  }'

Connect with SSH

Link your SSH key, then connect with: ssh hacker@dojo.idg.ctf

Batch Dependencies

Chain requests using ParentIds to use results from previous requests.

Objective

Create a batch where:

  1. First request searches for a point
  2. Second request uses the WebId from the first result

Use ParentIds to create the dependency.

Example

curl -X POST http://challenge/piwebapi/batch \
  -H "Content-Type: application/json" \
  -d '{
    "search": {"Method": "GET", "Resource": "/piwebapi/search/query?q=name:FLOW*"},
    "getValue": {"Method": "GET", "Resource": "/piwebapi/streams/{0}/value", "ParentIds": ["search"], "Parameters": ["$.Items[0].WebId"]}
  }'

Connect with SSH

Link your SSH key, then connect with: ssh hacker@dojo.idg.ctf

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score