Issue in consuming the APIs created using Dashboard API

Hi,
I am using Tyk Dashboard and Tyk Gateway. I am able to create APIs using Dashboard API. They are also visible in the dashboard. However, I cannot consume them untill I open the API in dashboard for edit and click on ‘Update’. For example, if I created an API with following definition using the dashboard API http://DOMAIN-NAME:3000/api/apis/:

{
    "api_definition": {
        "name": "test-api",
        "auth": {
            "auth_header_name": "authorization"
        },
        "definition": {
            "location": "header",
            "key": ""
        },
        "proxy": {
            "listen_path": "/test-api/",
            "target_url": "http://httpbin.org/"
        },
        "version_data": {
            "use_extended_paths": true,
            "not_versioned": true,
            "versions": {
                "Default": {
                    "expires": "",
                    "name": "Default",
                    "paths": {
                        "ignored": [],
                        "white_list": [],
                        "black_list": []
                    },
                    "extended_paths": {
                        "ignored": [
                            {
                                "path": "/test-api/",
                                "method_actions": {
                                    "GET": {
                                        "action": "no_action",
                                        "code": 200,
                                        "data": "",
                                        "headers": {}
                                    }
                                }
                            },
                            {
                                "path": "/test-api/reply",
                                "method_actions": {
                                    "GET": {
                                        "action": "reply",
                                        "code": 200,
                                        "data": "{\"foo\": \"bar\"}",
                                        "headers": {
                                            "x-test": "test"
                                        }
                                    }
                                }
                            }
                        ],
                        "white_list": [],
                        "black_list": []
                    },
                    "use_extended_paths": true
                }
            }
        },
        "use_oauth2": false,
        "oauth_meta": {
            "auth_login_redirect": "",
            "allowed_access_types": [],
            "allowed_authorize_types": []
        },
        "notifications": {
            "shared_secret": "",
            "oauth_on_keychange_url": ""
        },
        "enable_ip_whitelisting": false,
		    "allowed_ips": [],
        "use_keyless": false,
        "enable_signature_checking": false,
        "use_basic_auth": false,
        "active": true,
        "enable_batch_request_support": true
    },
    "hook_references": [
        {
            "event_name": "QuotaExceeded",
            "hook": {
                "api_model": {},
                "id": "54be6c0beba6db07a6000002",
                "org_id": "54b53d3aeba6db5c35000002",
                "name": "Test Post",
                "method": "POST",
                "target_path": "http://httpbin.org/post",
                "template_path": "",
                "header_map": {
                    "x-tyk-test": "123456"
                },
                "event_timeout": 0
            },
            "event_timeout": 60
        }
    ]
}

and try to access the API http://DOMAIN-NAME:8080/test-api/reply then it throws following error:

<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>

Now, if I edit the API in dashboard and click Update without any changes then I get the following expected result:
{“foo”: “bar”}

Am I required to explicitly call more of the Dashboard or Gateway APIs (say to reload) after the creation of new API?

Any pointers would be helpful.

Hi Ahamid,

It normally takes about 10 seconds for changes made to the Dashboard to propagate. Are you able to confirm that you’ve waited at least 10 seconds before attempting to access the /test-api/reply path?

Regards,
Jess @ Tyk

Hi Jess,

Thanks for the reply. Yes, I waited for few hours. Will check again tomorrow.

Regards,
Abbas

Hi Jess,

Thanks for looking into the issue. The APIs started working as expected after making below change in the API definition while posting to http://DOMAIN-NAME:3000/api/apis/. Here I just changed the order of the extended paths. If this is really a solution then it would be nice to update the same at https://tyk.io/tyk-documentation/tyk-dashboard-api/api-definitions/ under the section ‘Create API Definition’. Otherwise, I will try analyse why it started working only after making this change.

EARLIER:

                "extended_paths": {
                    "ignored": [
                        {
                            "path": "/test-api-1/",
                            "method_actions": {
                                "GET": {
                                    "action": "no_action",
                                    "code": 200,
                                    "data": "",
                                    "headers": {}
                                }
                            }
                        },
                        {
                            "path": "/test-api-1/reply",
                            "method_actions": {
                                "GET": {
                                    "action": "reply",
                                    "code": 200,
                                    "data": "{\"foo\": \"bar\"}",
                                    "headers": {
                                        "x-test": "test"
                                    }
                                }
                            }
                        }
                    ],

UPDATED:

                "extended_paths": {
                    "ignored": [
                        {
                            "path": "/test-api-1/reply",
                            "method_actions": {
                                "GET": {
                                    "action": "reply",
                                    "code": 200,
                                    "data": "{\"foo\": \"bar\"}",
                                    "headers": {
                                        "x-test": "test"
                                    }
                                }
                            }
                        },
                        {
                            "path": "/test-api-1/",
                            "method_actions": {
                                "GET": {
                                    "action": "no_action",
                                    "code": 200,
                                    "data": "",
                                    "headers": {}
                                }
                            }
                        }
                    ],

Regards,
Abbas

Hi Abbas,

Just to confirm, has this issue been resolved? If so, was the change to the order in which the ignored paths appeared in the extended_paths object the only change that was made?

Regards,
Jess @ Tyk

Hi Jess,

Yes the issue is resolved. Today, I again tested the scenario and could confirm that the API works just by changing the order of ignored paths. It would be great if someone else could also test this and confirm. If results are same, updating the document would save newbies time.

Thanks for your help and following up.

  • Abbas