2020-05-31 12:48:21 UTC - Lars Trieloff: Hi, is there a way to get a web action (regular, not raw) to handle requests sent with `accept: application/json` headers? Right now, I’m getting a `HTTP 406: Resource representation is only available with these types:\ntext/html; charset=UTF-8` error. I know that changing the URL to include `.json` gives we a raw JSON response, but ideally I’d like my action to be able to handle all requests. https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590929301367000 ---- 2020-05-31 13:17:54 UTC - Rodric Rabbah: can you confirm your action is actually returning json? https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931074369300 ---- 2020-05-31 13:18:06 UTC - Rodric Rabbah: ```> cat ex.js function main(args) { return { body: { msg: 'ok' } } }```
https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931086369600?thread_ts=1590931086.369600&cid=C3TPCAQG1 ---- 2020-05-31 13:18:25 UTC - Rodric Rabbah: vs ```function main(args) { return { body: 'oops' } }``` https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931105369900?thread_ts=1590931105.369900&cid=C3TPCAQG1 ---- 2020-05-31 13:18:44 UTC - Rodric Rabbah: the first is correct (when the request accept header is json) the second is not https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931124370500?thread_ts=1590931124.370500&cid=C3TPCAQG1 ---- 2020-05-31 13:19:13 UTC - Rodric Rabbah: ```> curl -H'accept: application/json' `wsk action get ex --url` {"code":"f3e81fce2ace139ba7e80946c710326b","error":"Resource representation is only available with these types:\ntext/html; charset=UTF-8"}``` https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931153370600?thread_ts=1590931105.369900&cid=C3TPCAQG1 ---- 2020-05-31 13:19:30 UTC - Rodric Rabbah: ```> curl -H'accept: application/json' `wsk action get ex --url` { "msg": "ok" }``` https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931170370800?thread_ts=1590931086.369600&cid=C3TPCAQG1 ---- 2020-05-31 13:20:13 UTC - Rodric Rabbah: the url in both examples posted does not have a .json extension - or any other extension https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590931213371100?thread_ts=1590931124.370500&cid=C3TPCAQG1 ---- 2020-05-31 17:26:57 UTC - Lars Trieloff: That makes sense. I thought my action would return JSON, but there may be something I’m missing. https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590946017372000 ---- 2020-05-31 18:10:23 UTC - Lars Trieloff: It turns out I had a couple of plain text `body` values that I ran into when I didn’t expect it. Thanks for the help, @Rodric Rabbah +1 : Rodric Rabbah https://openwhisk-team.slack.com/archives/C3TPCAQG1/p1590948623372900 ----
