2 Replies Latest reply on Jul 17, 2018 6:30 AM by ChristopherWeh

    PIwebAPI Python client searchByAttribute


      Hello together,


      at the moment I am trying to perform a search by attribute request using the Python PIwebAPI clinet. Am I right, that in the currently published version multiple ValueQueries are not allowed in the eventFrame.create_search_by_attribute method?


      If not could you add a working example to the docs.


      Thanks for your help



        • Re: PIwebAPI Python client searchByAttribute
          Marcos Vainer Loeff

          Hello Christopher,


          This is an example using element.create_search_by_attribute():


          client = self.getPIWebApiClient()
          element = client.element.get_by_path("\\\\PISRV1\\City Bikes\\(TO)BIKE Torino")
          element_template = client.elementTemplate.get_by_path("\\\\PISRV1\\City Bikes\\ElementTemplates[BikeStationTemplate]")
          value_query1 = PIValueQuery(attribute_name="Latitude", attribute_value=0, search_operator="GreaterThan")
          values_queries = list()
          search_by_attribute = PISearchByAttribute(search_root=element.web_id, element_template  = element_template.web_id, value_queries = values_queries);
          response = client.element.create_search_by_attribute(search_by_attribute, False)



          I guess you can do something similar for EF.


          Let me know if this works!

            • Re: PIwebAPI Python client searchByAttribute

              Hello Marcos,


              this works for me just fine. However, the eventFrame, which I am searching for is way back in the past, therefore I have to add the startTime property to the execute_search_by_attribute request.


              To do this I changed tow lines in the event_frame_api:

              return self.api_client.call_api('/eventframes/searchbyattribute', 'POST',




              body =body_params,

              post_params =form_params,

              files =local_var_files,

              response_type ='PIItemsEventFrame',



              _preload_content =params.get('_preload_content', True),


              collection_formats =collection_formats)


              Because I am interested in the response header where the search id is stored and not in the (almost) empty response body.


              And then by adding the following tow lines to your code:




              Best Regards,