Cannot see the posted policy in Tyk Open Source Gateway

Hi,

I am using Tyk Open Source Gateway (Docker version) to create a policy. Here is my policy definition:

{
name: “oauth-test-api-policy”,
rate: 20,
per: 1,
quota_max: 1000,
quota_renewal_rate: 90000,
access_rights: {
oauth-test-api: {
api_name: “oauth-test-api”,
api_id: “oauth-test-api”,
versions: [
“Default”
],
allowed_urls: []
}
}
}

I saved this JSON into a file called policy3.json.

Then I used this url to post this JSON to create the policy:

curl -H ‘x-tyk-authorization:foo’ -X POST -d @policy3.json http://localhost:8080/tyk/policies

After that I saw the message:
{“key”:"",“status”:“ok”,“action”:“added”}

However, when I tried to use the following url to get the policy, I only saw one policy, which is came with the Tyk Gateway, and couldn’t see the policy I created:

[
{
“_id”: “”,
“id”: “”,
“name”: “”,
“org_id”: “54de205930c55e15bd000001”,
“rate”: 1000,
“per”: 1,
“quota_max”: 100,
“quota_renewal_rate”: 60,
“throttle_interval”: 0,
“throttle_retry_limit”: 0,
“max_query_depth”: 0,
“access_rights”: {
“41433797848f41a558c1573d3e55a410”: {
“api_name”: “My API”,
“api_id”: “41433797848f41a558c1573d3e55a410”,
“versions”: [
“Default”
],
“allowed_urls”: null,
“restricted_types”: null,
“limit”: {
“rate”: 0,
“per”: 0,
“throttle_interval”: 0,
“throttle_retry_limit”: 0,
“max_query_depth”: 0,
“quota_max”: 0,
“quota_renews”: 0,
“quota_remaining”: 0,
“quota_renewal_rate”: 0
},
“field_access_rights”: null,
“allowance_scope”: “”
}
},
“hmac_enabled”: false,
“enable_http_signature_validation”: false,
“active”: false,
“is_inactive”: false,
“tags”: null,
“key_expires_in”: 0,
“partitions”: {
“quota”: false,
“rate_limit”: false,
“complexity”: false,
“acl”: false,
“per_api”: false
},
“last_updated”: “”,
“meta_data”: null,
“graphql_access_rights”: null
}
]

I did the hot reload, restart also. But still cannot see the created policy. The Tyk gateway image version I used is v4.1.0-rc10.

How to create a policy in Tyk Open Source Gateway? Is there any reason why I can’t see the created policy? Any step I missed?

Thanks.

Regards,

Maan Tarng

For starters, the policy definition is wrongly formatted in json. Your keys are missing the required quotes. Try fixing that and try again.

@Olu Thanks for the suggestion. I will try that.