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

Incorrect curl commands #8482

Open
2 tasks done
rajeevramani opened this issue Feb 28, 2025 · 1 comment
Open
2 tasks done

Incorrect curl commands #8482

rajeevramani opened this issue Feb 28, 2025 · 1 comment

Comments

@rajeevramani
Copy link

Where is the problem?

On this page https://docs.konghq.com/gateway/3.9.x/key-concepts/routes/expressions/ there is a documentation that says

Create routes with expressions

To create a new route object using expressions, send a POST request to the services endpoint:

curl --request POST \
  --url http://localhost:8001/services/example-service/routes \
  --form-string expression='http.path == "/mock"'

What is your suggestion?

The curl command is incorrect

(The service example-service has been created)

This curl command is incorrect and results in a message

{"code":2,"fields":{"expression":"unknown field","@entity":["must set one of 'methods', 'hosts', 'headers', 'paths', 'snis' when 'protocols' is 'https'"]},"message":"2 schema violations (must set one of 'methods', 'hosts', 'headers', 'paths', 'snis' when 'protocols' is 'https'; expression: unknown field)","name":"schema violation"}

Code of Conduct and Community Expectations

  • I agree to follow this project's Code of Conduct
  • I agree to abide by the Community Expectations
@javicps
Copy link
Contributor

javicps commented Mar 8, 2025

Actually the command is correct, but you need to satisfy the prerequisite indicated in the documentation:
Edit the kong.conf to contain the line router_flavor = expressions and restart Kong Gateway.
Without it, the expressions are not accepted in the API calls

Once router_flavor = expressions is added, the CURL command works as expected:

curl --request POST \
  --url http://localhost:8001/services/example-service/routes \
  --form-string expression='http.path == "/mock"'
HTTP/1.1 201 Created
Date: Sat, 08 Mar 2025 19:17:41 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Kong-Admin-Request-ID: 85d16e0f5128c955985eb3586cb25c4a
Content-Length: 520
X-Kong-Admin-Latency: 327
Server: kong/3.9.0.0-enterprise-edition

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