Cannot create an API using the Dashboard API

Hi,

I am not able to create an API, sample request using as:

{
“name”: “Galaxy Stars”,
“auth”: {
“use_param”: false,
“param_name”: “”,
“use_cookie”: false,
“cookie_name”: “”,
“auth_header_name”: “authorization”,
“use_certificate”: false
},
“definition”: {
“location”: “header”,
“key”: “version”,
“strip_path”: false
},
“proxy”: {
“preserve_host_header”: false,
“listen_path”: “/api”,
“target_url”: “http://httpbin.org/”,
“strip_listen_path”: true,
“enable_load_balancing”: false,
“target_list”: ,
“check_host_against_uptime_tests”: false,
“service_discovery”: {
“use_discovery_service”: false,
“query_endpoint”: “”,
“use_nested_query”: false,
“parent_data_path”: “”,
“data_path”: “”,
“port_data_path”: “”,
“target_path”: “”,
“use_target_list”: false,
“cache_timeout”: 0,
“endpoint_returns_list”: false
},
“transport”: {
“ssl_ciphers”: ,
“ssl_min_version”: 0,
“proxy_url”: “”
}
},
“use_keyless”: false,
“active”: true,
“use_oauth2”: false,
“oauth_meta”: {
“auth_login_redirect”: “”,
“allowed_access_types”: ,
“allowed_authorize_types”: [
“token”
]
},
“notifications”: {
“shared_secret”: “”,
“oauth_on_keychange_url”: “”
},
“enable_ip_whitelisting”: false,
“allowed_ips”: ,
“enable_signature_checking”: false,
“use_basic_auth”: false,
“enable_batch_request_support”: true,
“version_data”: {
“use_extended_paths”: true,
“not_versioned”: false,
“default_version”: “”,
“versions”: {
“1.1”: {
“name”: “1.1”,
“expires”: “”,
“paths”: {
“ignored”: ,
“white_list”: ,
“black_list”:
},
“global_headers”: {},
“global_headers_remove”: ,
“global_size_limit”: 0,
“override_target”: “”,
“use_extended_paths”: true,
“extended_paths”: {
“track_endpoints”: [{
“path”: “/test-path/”,
“method_actions”: {
“GET”: {
“action”: “no_action”,
“code”: 200,
“data”: “”,
“headers”: {}
}
}
},
{
“path”: “/test-path/reply”,
“method_actions”: {
“GET”: {
“action”: “reply”,
“code”: 200,
“data”: “{"foo": "bar"}”,
“headers”: {
“x-test”: “test”
}
}
}
}
],
“ignored”: ,
“white_list”: ,
“black_list”:
}
}
}
},

“tags”: ,

“global_rate_limit”: {
“rate”: 0,
“per”: 0
},
“strip_auth_data”: false,
“disable_rate_limit”: false,
“is_site”: false,
“sort_by”: 0,
“hook_references”:
}

Using the above request it says:

{
“Status”: “Error”,
“Message”: “API object validation failed.”,
“Meta”: null,
“Errors”: [
“auth: Additional property auth is not allowed”,
“definition: Additional property definition is not allowed”,
“active: Additional property active is not allowed”,
“strip_auth_data: Additional property strip_auth_data is not allowed”,
“name: Additional property name is not allowed”,
“oauth_meta: Additional property oauth_meta is not allowed”,
“version_data: Additional property version_data is not allowed”,
“tags: Additional property tags is not allowed”,
“global_rate_limit: Additional property global_rate_limit is not allowed”,
“use_keyless: Additional property use_keyless is not allowed”,
“enable_ip_whitelisting: Additional property enable_ip_whitelisting is not allowed”,
“use_basic_auth: Additional property use_basic_auth is not allowed”,
“enable_batch_request_support: Additional property enable_batch_request_support is not allowed”,
“enable_signature_checking: Additional property enable_signature_checking is not allowed”,
“disable_rate_limit: Additional property disable_rate_limit is not allowed”,
“proxy: Additional property proxy is not allowed”,
“use_oauth2: Additional property use_oauth2 is not allowed”,
“notifications: Additional property notifications is not allowed”,
“allowed_ips: Additional property allowed_ips is not allowed”
]
}

While another example from the website is working as:

{
“api_definition”: {
“name”: “Test”,
“auth”: {
“auth_header_name”: “authorization”
},
“definition”: {
“location”: “header”,
“key”: “”
},
“proxy”: {
“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-path/”,
“method_actions”: {
“GET”: {
“action”: “no_action”,
“code”: 200,
“data”: “”,
“headers”: {}
}
}
},
{
“path”: “/test-path/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”: [
“token”
]
},
“notifications”: {
“shared_secret”: “”,
“oauth_on_keychange_url”: “”
},
“enable_ip_whitelisting”: true,
“allowed_ips”: [
“127.0.0.1”
],
“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
}
]
}

Are we restricted on what properties can be set during API creation?

Hi
I would check your definitions with a json linter first. I think you are injecting invalid quote characters on your end.
“ vs "
Thanks
Josh

Hi,

I already checked this, no issue around quote characters.
These got applied, when I pasted the code above, and added it under a code block

Any other tips?

Hi,

Any more feedback on this? This seems to be a bug

Hi,

You need to wrap your API definition inside api_definition field. Don’t put hook_references inside api_definiton, it will remain as a separate field.

You can refer below link for details about how to use Dashboard API
https://tyk.io/docs/tyk-dashboard-api/api-definitions/