Forum Discussion

SurendaRr_34988's avatar
SurendaRr_34988
Icon for Nimbostratus rankNimbostratus
Jan 27, 2018

Filter parameter in through API is not working for ASM policies V12.12

Guys,

 

i am looking for an API structure with filter parameter which will allow me to obtain the Hash Value for Selected ASM policy in F5. I have tried with the below API through Curl and it give me the whole bunch of hash codes for all the ASM policies in the device(Unable to filter one policy)

 

curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" GET $filter=name eq ASM_Demo

 

1 Reply

  • Ensure you escape or add the encoding for the "$" and encode the space characters.

    Examples against 12.1.2:

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies | jq .items[].name

    "ASM_Policy_1"

    "Sharepoint_Policy"

    "Exchange2010_CAS_Services"

    "Portal_Policy1"

    "Maps_Policy"

    "External_Policy_1"

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies?\$filter=name%20eq%20Maps_Policy | jq .items[].name

    "Maps_Policy"

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies?%24filter=name%20eq%20Maps_Policy | jq .items[].name

    "Maps_Policy"

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies | jq -c '.items[] | [{ ID: .id, Name: .name }]'

    [{"ID":"EDrCrURQ0zNEXKR-7TGRPg","Name":"ASM_Policy_1"}] [{"ID":"rp76DF4GDQkAHssIm5yIVQ","Name":"Sharepoint_Policy"}] [{"ID":"jy0zD_fvPQ6GdVteE1qosA","Name":"Exchange2010_CAS_Services"}] [{"ID":"2FHNd0d4D6gDqlSvX5KEew","Name":"Portal_Policy1"}]

    [{"ID":"G3-kYFxnsQjasSQSqwJpuQ","Name":"Maps_Policy"}]

    [{"ID":"5jvgsA4GWEpZrbGKoc62Vw","Name":"External_Policy_1"}]

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies?%24filter=name%20eq%20GIS_Maps | jq -c '.items[] | [{ ID: .id, Name: .name }]'

    [{"ID":"G3-kYFxnsQjasSQSqwJpuQ","Name":"GIS_Maps"}]

    curl -u admin:admin --silent -k1 -H "Accept:application/json" -H "Content-Type:application/json" https://10.10.10.3/mgmt/tm/asm/policies?%24filter=name%20eq%20GIS_Maps | jq '.items[].id'

    "G3-kYFxnsQjasSQSqwJpuQ"

    If you are unsure of the query, use Postman or similar. If the filter returns the desired results, it's likely you need to escape or encode what you are sending via the command line.