搭建OpenWhisk后无法找到并调用Web Action URL求助
Hey there! Let's work through getting your OpenWhisk Web Action URL sorted out so you can start calling it. Here's a step-by-step breakdown to fix this issue:
1. First, Finish Creating the Web Action Correctly
It looks like your wsk action create command was cut off—you need to add the flag that marks the action as a Web Action. Use either --web true (for JSON-formatted responses) or --web raw (for raw HTTP outputs like HTML/plain text). The full command should be:
wsk action create demo1/hello hello.js --web true -i
The -i flag matches what you used for package creation, which I assume is for targeting a local/self-hosted OpenWhisk instance or bypassing certificate checks.
2. Retrieve the Web Action URL
Once the action is properly created, run this command to fetch its dedicated URL:
wsk action get demo1/hello --url -i
You’ll get an output similar to this:
ok: got action demo1/hello
https://your-openwhisk-host/api/v1/web/your-namespace/demo1/hello.json
your-openwhisk-host: The address of your OpenWhisk instance (e.g.,localhost:3233for a local deployment)your-namespace: Your OpenWhisk namespace (runwsk namespace list -iif you’re unsure—default is usuallyguest)- The
.jsonsuffix: Use this for JSON responses; if you used--web raw, replace it with.raw
3. Test the Web Action
Now you can call it via curl or directly in your browser:
- Using curl (add
-kif you’re using a self-signed certificate):curl -k https://your-openwhisk-host/api/v1/web/your-namespace/demo1/hello.json -i - Or paste the full URL into your browser (ignore certificate warnings for local instances if needed)
Quick Troubleshooting Checks
- Confirm your OpenWhisk host port: Local deployments often use port 3233 for the API gateway (web actions require the gateway, not the direct controller port)
- Verify the action’s web status: Run
wsk action get demo1/hello -iand check theweb-exportfield in the metadata—it should be set totrueorraw - Ensure your namespace matches: The URL must use the exact namespace you’re working in
内容的提问来源于stack exchange,提问作者thach.nv92

