Searching the management UI using basepath or URL

Not applicable

You can search for proxies in the management ui by name, environment or date modified. I was wondering if there is a way of searching for a basepath or a url in proxies either using the management ui or management api.

0 12 1,041
12 REPLIES 12

Searching for API proxies by proxy base path is not supported by the Management API or UI.

A potential solution to your problem would be to follow a proxy naming convention that correlates to the proxy base path. This will allow you to quickly identify a proxy from its base path (and vice versa).

For example, if your proxy base path is /products/v1, the proxy should be named products-v1. You can apply this same naming convention to other entities of Edge (e.g. KVM: products-v1-config, Cache resource: products-v1-responses, etc.)

You can use a "brute force" search. Query each API proxy and examine the basepath for each proxy endpoint.

Not applicable

@Demesew Abebe: There is no strait forward management api to search proxies by proxy base path.

As proxy base path is unique, so one proxy must be mapped with one proxy base path. If you do some naming convention, your proxy search result would be either 1 or 0.

Could you please share what you actually looking for or kind of use case?

Hi @Demesew Abebe

There is no direct Mgmt API for your use case. You will have to write some custom logic with Mgmt APIs to achieve that. The logic is:

1) Get all APIs

2) With the list of APIs - you need to iterate and get the latest revisions of these APIs using this API

3) Once you have the revision, use this API to get the Proxy info that has the basepath config in the response as well

I have built a Node proxy orchestrating the above - Check this out. I did this out of curiosity 🙂

Take a look and follow the steps there. It should give you the list of proxies (all or by search qp)

Hi @Sai Saran Vaidyanathan

Thank you for doing this. Exactly what I am looking for. I have cloned and deployed successfully. But I am getting error when I am making calls. Here is the error:-

{ "fault": { "faultstring": "JavaScript execution failed: connect EINVAL", "detail": { "errorcode": "scripts.node.ScriptExecutionError" } } }

Edge UI is also showing "Redefinition of 'Promise .' " error on the server.js file line # 6.

Can you please take a look?

Hi @Demesew Abebe - Can you confirm if the node_modules is also deployed ? And that includes promise as well ?

Also can you try running it locally ? I mean navigate to the apiproxy/resources/node directory on your machine and then run "node server.js". It should run on http://localhost:9000. With this, you can run it on your POSTMAN pointing to this URL.. See if that works..

HI @Demesew Abebe - Did that work ?

HI @ Sai Saran Vaidyanathan

  • I did try it offline and it worked.
  • The node_module is zipped and deployed including promise.
  • v1/apis worked too from edge
  • I am getting error for the following
    • /v1/o/orgname/apis
    • /v1/o/orgname/apis/apiname/revisions/revision#
    • error:-

    { "fault": { "faultstring": "Script node executed prematurely: TypeError: Cannot call method \"use\" of undefined\nTypeError: Cannot call method \"use\" of undefined\n at /organization/environment/api/server.js:13\n at module.js:456\n at module.js:474\n at module.js:356\n at module.js:312\n at module.js:497\n at startup (trireme.js:142)\n at trireme.js:923\n", "detail": { "errorcode": "scripts.node.runtime.ScriptExitedError" } }}

  • Please take a look when you get a chance

Hi @Demesew Abebe

Thanks for getting back

Need the following:

1) Can you export the bundle and attach it ?

2) What is the curl command you are running ?

3) not sure what you are trying with /v1/o/org/apis ??

If you share me the bundle, I can provide more info

Sorry for the late response. I am the bundle.

basepathnodeapi-rev1-2017-08-03.zip

curl --request GET \
  --url 'http://{org}-{env}.apigee.net/v1/apis/basepaths/?search=abc' \
  --header 'authorization: Basic ZGVtZX***' \
  --header 'content-type: application/json' \
  --header 'x-host: api.enterprise.apigee.com' \
  --header 'x-org: {myOrg}'

Now I am getting empty array and 200Ok from postman and the following message from edge UI trace

*** Starting script Magic happens on port 9000 [Error: This socket is closed.] *** Error in Node.js script: "connect EINVAL": null

Hi @Demesew Abebe - Can you run it locally.. In your terminal, navigate to apiproxy/resources/node and run "node server.js"

The API should run on your local machine. Please run the same call in POSTMAN pointing to localhost 9000 and see what issue you get. You can debug by putting console out statements or by running it on nodemon

Hi @Sai Saran Vaidyanathan, here is my curl request and corresponding error

curl --request GET \
  --url 'http://{myOrg}-{myEnv}.apigee.net/v1/apis/basepaths?search=v1' \
  --header 'authorization: ZGVtZ***' \
  --header 'content-type: application/json' \
  --header 'x-host: api.enterprise.apigee.com' \
  --header 'x-org: {myOrg}'

error:-

{
	"fault": {
		"faultstring": "JavaScript execution failed: Empty JSON string: SyntaxError: Empty JSON string\n    at \/organization\/environment\/api\/server.js:128\n    at emit (events.js:117)\n    at _stream_readable.js:943\n    at _tickDomainCallback (trireme.js:491)\n    at _tickFromSpinner (trireme.js:422)\n",
		"detail": {
			"errorcode": "scripts.node.ScriptExecutionError"
		}
	}
}

I tried it in my local with below curl script :-

curl --request GET \
  --url 'http://localhost:9000/v1/apis/basepaths?search=v1' \
  --header 'authorization: ZGVtZ***' \
  --header 'content-type: application/json' \
  --header 'x-host: api.enterprise.apigee.com' \
  --header 'x-org: {myOrg}'

and the response is:-

Cannot GET /v1/apis/basepaths?search=v1