AnsweredAssumed Answered

PI WEB API BATCH GET/POST

Question asked by GuillaumeC on Aug 7, 2020

Hi, 

 

I'm searching to be able to GET/PUT multiple pi point value with the batch request. I make three case two GET Method and one PUT Method. 

 

  • CASE GET 1: 

{
"QueryElements":
{
"Method": "GET",
"Resource": "https://hostname/piwebapi/assetdatabases/databasewebid/elements?searchFullHierarchy=true&maxCount=50000",
},
"QueryForAttributes":
{
"Method": "GET",
"RequestTemplate": {"Resource": "https://hostname/piwebapi/streamsets/{0}/value?searchFullHierarchy=true&maxCount=50000"},
"ParentIds": ["QueryElements"],
"Parameters": ["$.QueryElements.Content.Items[*].WebId"]
}
}

Result: I got the expected result

 

  • CASE  GET 2:

{
"QueryElements":
{
"Method": "GET",
"Resource": "https://hostname/piwebapi/dataservers/dataserverwebid/points?namefilter=*SINU*"
},
"QueryForAttributes":
{
"Method": "GET",
"RequestTemplate": {"Resource": "https://hostname/piwebapi/streamsets/{0}/value"},
"ParentIds": ["QueryElements"],
"Parameters": ["$.QueryElements.Content.Items[*].WebId"]
}
}

Result:

  •   "QueryElements"

OK

  • "QueryForAttributes"

Error message: Unknown or invalid WebID format: 'WebId' 

But when I try https://hostname/piwebapi/streams/WebId/value with this WebId I got a result...

 

  • CASE POST 1:
{
"QueryElements":
{
"Method": "GET",
"Resource": "https://hostname/piwebapi/streams/webid/value}",
},
"QuerytoUpdateValue":
{
"Method": "POST",
"Ressource":"QueryElements",
"Content": {"\"Value":\"Test pour batch\"}
}
}
  • Result: 

Error: 400 Bad request, I get there is something wrong in the "QuerytoUdate"

 

Do you have an explanation for the case 2, why do I have this message while the URL works ? 

Do you see where I've done wrong on the case 3?

 

 

 

Outcomes