AnsweredAssumed Answered

PI WebAPI Batch Request ParentID Parameter

Question asked by aegelhof on Jul 8, 2019
Latest reply on Jul 8, 2019 by rschmitz

Hello,

 

I’m having a issue with a batch request using ParentIDs.  Specifically, using parameters (I think).  I’m using the following body content below, the idea here is to create a PI tag and then create an element with the same name using a GET request after the fact to get the tag name to be used in the name of the AF element being created.  I’m guessing I have a syntax error in the parameter element.  I looked at the documentation for JSONPath but I’m not having much luck.  Any insights anyone can provide?

 

 

Body Content:

 

 

WORKING:

{

"CreateTag"       :{

                "Method":"POST",

             "Resource":"https://SERVERNAME/piwebapi/dataservers/F1DSUg9RgGAqQUap9GVsKYIDXwREVWRUxPUDI/points",

                "Content": "{'Name' : 'TestTag3','PointClass': 'classic','PointType': 'Float32','Future': false}"

},

"GetTagName":{

                "Method":"GET",

                "ParentIDs":["CreateTag"],

                "Parameters":["$.CreateTag.Headers.Location"],

                "Resource":"{0}"

},

"CreateElement":{

                "Method":"POST",

                "ParentIDs":["GetTagName"],

                "Parameters":["$.GetTagName.Content.Name"],

                "Resource": "https://SERVERNAME/piwebapi/assetdatabases/F1RDR7ftT9N1JUm5hpKmIGX_5Q56nxrB6-30CkjGNH9ha9fgREVWRUxPUDJcQU5EWQ/elements",

                "Content":"{\"Name\":\"TestTag3\"}"

}

}

 

NOT WORKING:

 

{

"CreateTag"       :{

                "Method":"POST",

             "Resource":"https://SERVERNAME/piwebapi/dataservers/F1DSUg9RgGAqQUap9GVsKYIDXwREVWRUxPUDI/points",

                "Content": "{'Name' : 'TestTag3','PointClass': 'classic','PointType': 'Float32','Future': false}"

},

"GetTagName":{

                "Method":"GET",

                "ParentIDs":["CreateTag"],

                "Parameters":["$.CreateTag.Headers.Location"],

                "Resource":"{0}"

},

"CreateElement":{

                "Method":"POST",

                "ParentIDs":["GetTagName"],

                "Parameters":["$.GetTagName.Content.Name"],

                "Resource": "https://SERVERNAME/piwebapi/assetdatabases/F1RDR7ftT9N1JUm5hpKmIGX_5Q56nxrB6-30CkjGNH9ha9fgREVWRUxPUDJcQU5EWQ/elements",

                "Content":"{\"Name\":\"{0}\"}"

}

}

 

Response using parameter:

{

    "CreateTag": {

        "Status": 201,

        "Headers": {

            "Location": "https://SERVERNAME/piwebapi/points/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM"

        },

        "Content": null

    },

    "GetTagName": {

        "Status": 200,

        "Headers": {

            "Content-Type": "application/json; charset=utf-8"

        },

        "Content": {

            "WebId": "F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM",

            "Id": 78350,

            "Name": "TestTag3",

            "Path": "\\\\SERVERNAME\\TestTag3",

            "Descriptor": "",

            "PointClass": "classic",

            "PointType": "Float32",

            "DigitalSetName": "",

            "EngineeringUnits": "",

            "Span": 100,

            "Zero": 0,

            "Step": false,

            "Future": false,

            "DisplayDigits": -5,

            "Links": {

                "Self": "https://SERVERNAME/piwebapi/points/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM",

                "DataServer": "https://SERVERNAME/piwebapi/dataservers/F1DSUg9RgGAqQUap9GVsKYIDXwREVWRUxPUDI",

                "Attributes": "https://SERVERNAME/piwebapi/points/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/attributes",

                "InterpolatedData": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/interpolated",

                "RecordedData": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/recorded",

                "PlotData": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/plot",

                "SummaryData": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/summary",

                "Value": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/value",

                "EndValue": "https://SERVERNAME/piwebapi/streams/F1DPUg9RgGAqQUap9GVsKYIDXwDjIBAAREVWRUxPUDJcVEVTVFRBRzM/end"

            }

        }

    },

    "CreateElement": {

        "Status": 400,

        "Headers": {

            "Content-Type": "application/json; charset=utf-8"

        },

        "Content": {

            "Errors": [

                "An exception has occurred. Please contact your PI Web API administrator for help in enabling debug mode."

            ]

        }

    }

}

 

 

 

Andy

Outcomes