You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/24 07:54:30 UTC
[GitHub] [apisix] imjoey commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?
imjoey commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-715876814
@membphis please see the request and response below:
```
➜ apisix git:(master) curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -i -d '
{
"username": "jack",
"plugins": {
"key-auth": {
"key": "auth-one"
},
"limit-count": {
"count": 2,
"time_window": 60,
"rejected_code": 503,
"key": "remote_addr"
}
}
}'
HTTP/1.1 405 Not Allowed
Transfer-Encoding: chunked
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Access-Control-Max-Age: 3600
Connection: keep-alive
Content-Type: application/json
Date: Sat, 24 Oct 2020 07:47:35 GMT
Keep-Alive: timeout=4
Proxy-Connection: keep-alive
Server: openresty
{"error_msg":"not supported `POST` method for consumer"}
```
The source code https://github.com/apache/apisix/blob/master/apisix/admin/consumers.lua#L105 also shows it up. I guess the reason is that the key of a consumer object equals to the value of `username` field, not equals to the `id` field as the other resources(route/upstream/services/ssl). Did I catch the point? Looking forward to your feedback. Thanks.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org