Wednesday, June 29, 2016

How to search specific API by name using new REST API in WSO2 API Manager 1.10

Lets say we have 3 APIs are created namely API, API1, API2. 
With the below curl command it will retrieve details of 3 APIs available. Because all of these APIs contained API as part of name.

curl -H "Authorization: Bearer 8551158c1"'API'
curl -H "Authorization: Bearer 94de782ddd64d3fea012bed4a71d764b"'Name:API'

But sometimes you may feel it didn't return you exact results (return only API and not API1, API2).
Reason is to match we used following regex and it will match with any string containing term in any place of string to be tested.
So if you need exact string match then we can do small hack for that. If you invoke API as follows and added ^ before search term and $ after search term it will return you exact match. See following command. Same applies for owner, content, version and other parameters too.

curl -H "Authorization: Bearer 94de782ddd64d3fea012bed4a71d764b"'Name:^CalculatorAPI$'

No comments:

Post a Comment