zhudock
Senior Member.
584 views

PPM 9.32 Filtering REST services

Is it possible to filter a REST service by a given field? For example

http://{server}:{port}/itg/rest/dm/requests?filter=(REQ.APPLICTION_NAME=MyAmazingApp)

0 Likes
6 Replies
Micro Focus Expert
Micro Focus Expert

Re: PPM 9.32 Filtering REST services

Hi,

If you upgrade to PPM 9.42 it is officially documented in the Interactive REST API on POST /rest2/dm/requestTypes/{id}/requests/advancedSearch . You can pass a payload with Token + Value to filter by this field like you would do in a PPM Advanced Request Search.

The same endpoint is available on /rest/ if you're stuck on 9.32, but keep in mind that it is not officially supported there. 

Cheers,

Etienne.

 

 

0 Likes
turif Regular Contributor.
Regular Contributor.

Re: PPM 9.32 Filtering REST services

Hi,

Can you help us by giving an example?

I tried this one on 9.32 but I got an exception.

http://[HOST]/itg/rest/dm/requestTypes/[nnnnn]/requests/advancedSearch

{
"value": "XXXXXX",
"token": "REQ.CUS_REALISIERER"
}

I got:

{

"ns2:error": {

"code": "PPMC_WSE000"
"detail": "javax.ws.rs.WebApplicationException"
"isWarning": "false"
"message": "Internal error."
}
}
can you help me what's wrong with it?
Thx,
 
Ferenc
0 Likes
Micro Focus Expert
Micro Focus Expert

Re: PPM 9.32 Filtering REST services

Hi Ferenc,

Obviously you have no idea what to pass as a POST payload for this REST API. I take it that you're stuck on PPM 9.32 and don't have access to a newer PPM version where Interactive REST API Help could guide you on the input. Well, you should definitely consider an upgrade, but until then here are some input to get you unstuck:

Here's the JSon payload example provided by the Interactive REST API on my PPM 9.5X instance:

{
  "fieldFilters": {
    "fieldFilterCondition": [
      {
        "fieldName": "string",
        "valueStrings": {
          "valueString": [
            "string"
          ]
        },
        "valueDates": {
          "valueDate": [
            "2019-01-24T03:54:08.511Z"
          ]
        },
        "isDateFieldType": true,
        "isAutoCompleteFieldType": true,
        "isYesNoFieldType": true,
        "isParameterField": true,
        "isUserDataField": true
      }
    ]
  }
}

Here are a few explanations:

Please note the trailing parameters "is...". If you set isDateFieldType to true, you'll need to fill in valueDates and remove valueStrings. If it is false (or not set), you need to fill in valueStrings and remove valueDates.

By default, this will user Request Header fields as filter criterias. If you want to filter using a Request Parameter field, you should set isParameterField to true. If you want to filter using a User Data field, you should set isUserDataField to true.  If you set both to true, well, turns out it'll be using Request Parameter fields, but I only know this because I can look at the source code - just don't do it 🙂 Note that this API is designed to filter on a single field per condition - but you can use multiple conditions if you want to filter by multiple fields.

The remaining parameters "isAutoCompleteFieldType" and "isYesNoFieldType" are self-explanatory, set them based on the type of the field you want to filter by. If all types fields are set to false, we consider that the filter field is a text field.

So, let's take an example: For request type ID 31090, I want to retrieve all requests in which the auto-complete request header field with Token "COMPANY" value is "MICRO_FOCUS". It's important to note that you have to filter by parameter value, NOT visible value. So for list validations, that means you should use CODE, not MEANING.

Here's the resulting JSon payload:

{
  "fieldFilters": {
    "fieldFilterCondition": [
      {
        "fieldName": "COMPANY",
        "valueStrings": {
          "valueString": [
            "MICRO_FOCUS"
          ]
        },
        "isDateFieldType": false,
        "isAutoCompleteFieldType": true,
        "isYesNoFieldType": false,
        "isParameterField": false,
        "isUserDataField": false
      }
    ]
  }
}

And that's it, you'll get some results:

{
  "request": [
    {
      "id": "42292",
      "description": "Cancel button on Scenario Detail changes"
    },
    {
      "id": "42145",
      "description": "Ability to restart a PPM Node / cluster from the admin console"
    },

... snip ...  

    {
      "id": "42039",
      "description": "Add Session KeepAlive feature to request creation page"
    }
  ]
}

I hope this helps,

Cheers,

Etienne.

0 Likes
turif Regular Contributor.
Regular Contributor.

Re: PPM 9.32 Filtering REST services

Hi Etienne,

Many thanks for the useful post! The filtering seems not working for me. I always get all the results. 

Btw. Can you help me in how to specity paging in case we have a huge resultset?

Thanks Again,

Ferenc

<ns2:error>
<code>PPMC_WSE113</code>
<message>There are 45369 requests to meet the search criteria, but the max allowed return requests are 10000, please modify the search criteria and search again.</message>
<isWarning>false</isWarning>
<detail>45369</detail>
<detail>10000</detail>
 </ns2:error>

 

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: PPM 9.32 Filtering REST services

There's no paging for this API Endpoint as filtering them would be expected to reduce their numbers enough not hit the limit  - as a workaround you could add some batching field to your requests and only retrieve requests for a specific batch number.

0 Likes
turif Regular Contributor.
Regular Contributor.

Re: PPM 9.32 Filtering REST services

Hi Etienne

Thanks for taking care of this thread.

My problem it that this filtering seems not working on 9.32. I always get all the resultset regardless the filter I set.

Request:
{
  "fieldFilters": {
    "fieldFilterCondition": [
      {
        "fieldName": "CUS_REALISIERER",
        "valueStrings": {
          "valueString": [
            "XXXXX"
          ]
        },
        "isDateFieldType": false,
        "isAutoCompleteFieldType": true,
        "isYesNoFieldType": false,
        "isParameterField": false,
        "isUserDataField": false
      }
    ]
  }
}

Response:

{
"ns2:error": {
"code": "PPMC_WSE113",
"detail": [
  "45371",
  "10000"
],
"isWarning": "false",
"message": "There are 45371 requests to meet the search criteria, but the max allowed return requests are 10000, please modify the search criteria and search again.",
"xmlns:ns2": "http://www.hp.com/ppm/core/"
}
}

Even If I set the valueString to a random value I always get the same response.

Do you know what could be the problem?

Thx,

Ferenc

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.