Basic_auth key creations using API

I’m attempting to create a key that will use basic auth and running across documentation links that suggest various different ways, all are different and none work. The two attempts below were taken from what I could find on the forums and from the documentation…

first attempt

curl -X "POST" "https://gatewayURL/api/apis/keys/basic/{username}" \
     -H 'x-tyk-authorization: authkey' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "hmac_string": "",
  "oauth_keys": {},
  "apply_policy_id": "",
  "tags": [],
  "jwt_data": {
    "secret": ""
  },
  "per": 1,
  "quota_renews": 1406121006,
  "basic_auth_data": {
    "password": "password"
  },
  "apply_policies": [],
  "is_inactive": false,
  "quota_remaining": 0,
  "meta_data": {},
  "monitor": {
    "trigger_limits": []
  },
  "allowance": 1000,
  "org_id": "org_id",
  "expires": -1,
  "hmac_enabled": false,
  "quota_max": -1,
  "access_rights": {
    "no idea what this is": {
      "api_id": "API_ID",
      "api_name": "API NAME",
      "versions": [
        "[\\"Default\\"]"
      ]
    }
  },
  "oauth_client_id": "",
  "rate": 10,
  "quota_renewal_rate": 60
}'

Response back is “404 page not found”

Second Attempt:

   curl -X "POST" "https://GatewayURL/tyk/keys/create" \
         -H 'x-tyk-authorization: authkey' \
         -H 'Content-Type: application/json; charset=utf-8' \
         -d $'{
      "hmac_string": "",
      "oauth_keys": {},
      "apply_policy_id": "",
      "tags": [],
      "jwt_data": {
        "secret": ""
      },
      "per": 1,
      "quota_renews": 1406121006,
      "basic_auth_data": {
        "username": "username",
        "password": "password"
      },
      "apply_policies": [],
      "is_inactive": false,
      "quota_remaining": 0,
      "meta_data": {},
      "monitor": {
        "trigger_limits": []
      },
      "allowance": 1000,
      "org_id": "org_id",
      "expires": -1,
      "hmac_enabled": false,
      "quota_max": -1,
      "access_rights": {
        "no idea what this is": {
          "api_id": "API_ID",
          "api_name": "API NAME",
          "versions": [
            "[\\"Default\\"]"
          ]
        }
      },
      "oauth_client_id": "",
      "rate": 10,
      "quota_renewal_rate": 60
    }'

Response back is “{“status”:“error”,“message”:“Failed to create key, ensure security settings are correct.”}”

This can be deleted, after viewing a bunch of docs, finally figured it out.

Do you happen to remember the solution? I’m running into your first scenario now.

@mattg , thank you for posting here and glad to know that it was resolved.

@jwoods , can you share your APIDefinition to us and the request you are making?

My problem was that I had set “use_keyless” to true in my API definition, which made it appear that authentication was not enabled. Setting this to false (along with the relevant use_basic_auth settings) allowed it to work.

@jwoods , Thank you for the confirmation. Can you clarify, if this is related to this post?