6 Replies Latest reply on Oct 30, 2017 7:18 PM by rxu

    PI WebAPI: Response 400 Bad Request

    KevinGoodspeed

      Hello there!

      Our requirement is to write "Calc Failed" in the "Value" attribute in the PI system.

      We are attempting to post data to PI end point https://*****/piwebapi/streamsets/recorded

      We sending a JSON body like below

      [{

          .......

          "Items": [{

              "Timestamp": "2017-10-11 01:00:00.000-0500",
              "Value": "Calc Failed",      
              "UnitsAbbreviation": "",
              "Good": false,
              "Questionable": true

          }]

      }]

      The response we getting is 400 Bad Request.

      We also tried the value as a JSON object like

      "Value": {

          "Name": "Calc Failed",

          "Value": "Calc Failed",    => 400 Bad Request

          "IsSystem": true

      }

       

       

      "Value": {

          "Name": "Calc Failed",

          "Value": 249,    => Works but we do not want to update the analog value

          "IsSystem": true

      }

       

       

      Please let us know what would be the correct format to post the data to resolve this issue.

        • Re: PI WebAPI: Response 400 Bad Request
          vkaufmann

          Your last option is really going to be the thing that works. Can you explain what you mean by "we do not want to update the analog value?"

           

          --Vince

            • Re: PI WebAPI: Response 400 Bad Request
              KevinGoodspeed

              249 is the analog value for digitial state "Calc Failed". It is representing a system state. However, our requirement is to have "Calc Failed" in the Value field. Do you know how to achieve that?

                • Re: PI WebAPI: Response 400 Bad Request
                  vkaufmann

                  You can't mix data types within a tag. So if you wish to write the literal string "Calc Failed" into the value alongside numerical data, this can't be accomplished. Can you explain why you do not want to use the system digital state?

                    • Re: PI WebAPI: Response 400 Bad Request
                      Bob_Knox

                      Hi Vincent -

                      I'm also working on this project so let me see if I can clarify the question.

                       

                      We are using a single tag using integrated quality, similar to just about every other PI interface (i.e. "Intf Shut", "Bad Value", "Calc Failed", etc. etc.).   Normally our tag will be the result of a forecasted value (i.e. 39MW) however there are circumstances where the forecast calculation cannot be calculated (i.e. bad inputs for wind speed), therefore the result of the calculation is the system digital state "Calc Failed".  

                       

                      Using PISDK or AFSDK, we can easily inject a system digital state ("Calc Failed") as an input parameter of the SDK update value method.    How is this accomplished using PI Web API?

                       

                      Does that help clarify this?

                       

                      Bob Knox

                • Re: PI WebAPI: Response 400 Bad Request
                  rxu

                  Hi Kevin,

                  To insert a system state value, the "Name" field has to be the state value name (a string), the "Value" field has to be the state value value (an integer) and the "IsSystem" has to be true. However, you don't need to specify all three fields. You can either specify "Name" field or "Value" field with "IsSystem" field. As for your use case, the following JSON object should work.

                   

                  "Value": {

                      "Name": "Calc Failed",

                      "IsSystem": true

                  }

                   

                  Thanks,

                  Rong