Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI Web API Reference

Batch Execute

Batch Execute

Execute a batch of requests against the service. As shown in the Sample Request, the input is a dictionary with IDs as keys and request objects as values. Each request object specifies the HTTP method and the resource and, optionally, the content and a list of parent IDs. The list of parent IDs specifies which other requests must complete before the given request will be executed. The example first creates an element, then gets the element by the response's Location header, then creates an attribute for the element. Note that the resource can be an absolute URL or a JsonPath that references the response to the parent request. The batch's response is a dictionary uses keys corresponding those provided in the request, with response objects containing a status code, response headers, and the response body. A request can alternatively specify a request template in place of a resource. In this case, a single JsonPath may select multiple tokens, and a separate subrequest will be made from the template for each token. The responses of these subrequests will returned as the content of a single outer response. Subrequests are always executed against the PI Web API instance that received the batch request. Any authority (host or port) specified by a subrequest URL is ignored. The batch endpoint cannot be used to make subrequests for external resources.

Request

POST batch

Body Parameter

The batch of requests.

Status Codes

207: A dictionary of response information corresponding to the batched requests.

Sample Request Body

{
  "1": {
    "Method": "POST",
    "Resource": "https://localhost/piwebapi/assetdatabases/D0NxzXSxtlKkGzAaZhKOB-KABJ2buwfWrkye3YhdL2FOUAUEhMQUZTMDRcQgYUUEVSRk9STUFOQ0UgVEVTVElORw/elements",
    "Content": "{\"Name\":\"New Element\"}"
  },
  "2": {
    "Method": "GET",
    "Resource": "$.1.Headers.Location",
    "ParentIds": [
      "1"
    ]
  },
  "3": {
    "Method": "POST",
    "Resource": "$.2.Content.Links.Attributes",
    "Content": "{\"Name\":\"New Attribute\"}",
    "ParentIds": [
      "2"
    ]
  },
  "4": {
    "Method": "GET",
    "Resource": "https://localhost/piwebapi/points?path=%5C%5CMyPIServer%5Csinusoid"
  },
  "5": {
    "Method": "GET",
    "Resource": "https://localhost/piwebapi/points?path=\\\\MyPIServer\\cdm158"
  },
  "6": {
    "Method": "GET",
    "Resource": "https://localhost/piwebapi/streamsets/value?webid={0}&webid={1}",
    "Parameters": [
      "$.4.Content.WebId",
      "$.5.Content.WebId"
    ],
    "ParentIds": [
      "4",
      "5"
    ]
  },
  "7": {
    "Method": "GET",
    "Resource": "https://localhost/piwebapi/assetdatabases/D0NxzXSxtlKkGzAaZhKOB-KABJ2buwfWrkye3YhdL2FOUAUEhMQUZTMDRcQgYUUEVSRk9STUFOQ0UgVEVTVElORw/elements"
  },
  "8": {
    "Method": "GET",
    "RequestTemplate": {
      "Resource": "$.7.Content.Items[*].Links.Attributes"
    },
    "ParentIds": [
      "7",
      "3"
    ]
  }
}
In This Topic
TitleResults for “How to create a CRG?”Also Available in