Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to create a key with curl #54

Closed
mNantern opened this issue Apr 21, 2015 · 1 comment
Closed

Impossible to create a key with curl #54

mNantern opened this issue Apr 21, 2015 · 1 comment

Comments

@mNantern
Copy link

I'd like to add a key to tyk manually in order to use my own key generation algorithm but I can't make it work:

curl -i -X PUT http://localhost:8080/tyk/keys/123 \
> --header "x-tyk-authorization: 352d20ee67be67f6341b4c0605b044b7" \
> --data '{
>     "allowance": 1000,
>     "rate": 1000,
>     "per": 60,
>     "expires": 1429359466,
>     "quota_max": -1,
>     "quota_renews": 1404121006,
>     "quota_remaining": 0,
>     "quota_renewal_rate": 60,
>     "access_rights": {
>         "1": {
>             "api_name": "Tyk Test API",
>             "api_id": "1",
>             "versions": [
>                 "Default"
>             ]
>         }
>     },
>     "org_id": ""
> }'

HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Sat, 18 Apr 2015 09:41:48 GMT
Content-Length: 46

{"status":"error","error":"Request malformed"}

It's working perfectly for with /tyk/keys/create

@lonelycode
Copy link
Member

Solved it :-) You need to add a content type header:

tyk@tyk-dev-env:~/$ curl -X POST http://localhost:8080/tyk/keys/989897876776567 --header "Content-Type:application/json" --header "x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7" --data '{
    "allowance": 999,
    "rate": 1000,
    "per": 60,
    "expires": 0,
    "quota_max": -1,
    "quota_renews": 1406121006,
    "quota_remaining": 0,
    "quota_renewal_rate": 60,
    "access_rights": {
        "3b7e73fd18794f146aab9c2e07b787bf": {
            "api_name": "Second Test API",
            "api_id": "3b7e73fd18794f146aab9c2e07b787bf",
            "versions": [
                "Default"
            ]
        }
    },
    "org_id": "53ac07777cbb8c2d53000002"
}'

Response: {"key":"989897876776567","status":"ok","action":"added"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants