Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
sudeepkm_analog
Contributor III
Contributor III

NPrinting API POST method Create new filter request

Dear All,

I would need help in Creating a Filter in NPrinting using NPrinting API call from POSTMAN.

I'm partially successful in creating the Filter by using NPrinting API however the filter values are not being set.

Given below are the steps I followed. 

Before creating the Request I got the correct App ID and Connection ID from NPrinting.

 https://<our np server>:4993/api/v1/filters

Request Body:

{
    "appId""698b1537-a034-48e5-bed0-49920f0bfeeb",
    "enabled"true,
    "name""sample_TEST",
    "Fields": {
        "ApiFilterField": {
            "connectionId""08e58504-b265-47d3-8003-eca73195f007",
            "name""AppFieldName",
            "overrideValues""false",
            "Values": {
                "ApiFilterFieldValue": {
                    "type""text",
                    "value""ApplicationFieldSampleValue"
                }
            }
        }
    }
}
 
I got response "code 201 Created"
 

I checked NPrinting and found the filter got created however no Fields added.

npcreatefilter.PNG

Can anyone please help me in this regard. Thanks in advance.

Apologies in advance in case I've missed any documents created on this issue already.

Thanks

@Frank_S , @Ruggero_Piccoli , @Lech_Miszkiewicz 

Labels (2)
2 Solutions

Accepted Solutions
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

My suggestion is to take Qlik Sense OnDemand NPrinitng Report extension and look how it is built. Since it already supports passing selections you will see there how it is done. 

Now - the filter api you described above does not take part in on demand requests I believe.... 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.

View solution in original post

Ruggero_Piccoli
Support
Support

Hi,

This is an example using Postman:

post create filter 2.png

the result is:

post create filter 2 result field.png

The JSON content:

{
    "appId""ab53ef11-3cdc-45af-9403-b788eba2b004",
    "enabled"true,
    "name""Created via API 2",
    "description""Example of a filter created via API Postman",
    "fields": [
        {
            "connectionId""07d36409-1a43-40ae-a682-e17f8929e9c6",
            "name""Country",
            "overrideValues"false,
            "selectExcluded"false,
            "values": [
                {
                    "value""USA",
                    "type""text"
                }
                ]
        }
                ],
   "variables": []
 }
 
I hope it helps.
Best Regards,
Ruggero


Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.

View solution in original post

5 Replies
sudeepkm_analog
Contributor III
Contributor III
Author

After further investigation I found the way. The issue was with how I created the JSON request string.

My JSON string was having unnecessary fields such as ApiFilterField and  ApiFilterFieldValue. After correcting it, I can see the values being added to the Filter.

{
"appId": "698b1537-a034-48e5-bed0-49920f0bfeeb",
"enabled": true,
"name": "sample_TEST",
"description": null,
"Fields": [{ "connectionId": "08e58504-b265-47d3-8003-eca73195f007",
"name": "AppFieldName",
"overrideValues": "false",
"Values":[ {
"type": "text",
"value": "ApplicationFieldSampleValue"
}]
}]}

My next hurdle is to add this Filter to the onDemandRequest for Report generation.

If anyone has any reference or example it would be really helpful. Thanks.

 

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

My suggestion is to take Qlik Sense OnDemand NPrinitng Report extension and look how it is built. Since it already supports passing selections you will see there how it is done. 

Now - the filter api you described above does not take part in on demand requests I believe.... 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

just like I thought...

https://help.qlik.com/en-US/nprinting/November2020/APIs/NP+API/index.html?page=34

and

https://help.qlik.com/en-US/nprinting/November2020/APIs/NP+API/index.html?page=93

 

 

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.
Ruggero_Piccoli
Support
Support

Hi,

This is an example using Postman:

post create filter 2.png

the result is:

post create filter 2 result field.png

The JSON content:

{
    "appId""ab53ef11-3cdc-45af-9403-b788eba2b004",
    "enabled"true,
    "name""Created via API 2",
    "description""Example of a filter created via API Postman",
    "fields": [
        {
            "connectionId""07d36409-1a43-40ae-a682-e17f8929e9c6",
            "name""Country",
            "overrideValues"false,
            "selectExcluded"false,
            "values": [
                {
                    "value""USA",
                    "type""text"
                }
                ]
        }
                ],
   "variables": []
 }
 
I hope it helps.
Best Regards,
Ruggero


Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
sudeepkm_analog
Contributor III
Contributor III
Author

@Lech_Miszkiewicz  @Ruggero_Piccoli 

Thanks so much for your help and suggestions in this regard. 

I also found how to create the JSON format request for generating Report along with Filter object in it.

       "type""report"
       "config": { 
        "reportId""0a0f095d-5109-4212-89d4-156bc3079469"
         "outputFormat""XLS" 
       } ,
       "filters": {
          "additionalFilters": ["fbfd854d-3c6e-4c3e-92a0-052a970f2d61"]
       }
}
One needs to carefully put the proper attribute values based on the Type mentioned in the API document.
such as array[String], String, String (Enum), OnDemandRequestConfig , OnDemandRequestFilters and array[FieldSelection] etc.
 
Again Thanks a lot to you experts for your constant help.