mpjjonker
mpjjonker

Reputation: 947

IBM Cloud Functions WebAction gives empty response (204)

I am running into strange behavior with IBM Cloud Functions. I have an Action that is web enabled (WebAction) for which I don't require authentication. I use Postman (and a browser) to test this new REST endpoint.(left side of the image below) The result is empty, an actual 204 No Content reponse.

But when I monitor the Action, I can see that it has been invoked and returned the expected JSON (right side of the image below). So the code is executed correctly.

enter image description here

When I perform a commandline invoke:

bx wsk action invoke --result talkToEoffice --param name FunctionWorld

I do see the expected result. Should I provide additional headers ?

Does this have something todo with synchronous (blocking) or non-blocking ?

Upvotes: 4

Views: 839

Answers (2)

Fábio Valentim
Fábio Valentim

Reputation: 3

Try to put extension .json in the end of URL API.

Ex

...API/web/test.json

Or you need explicitly convert some data, for example:

  • you pass {"dealerId:15}, your code need to have

anobject = Int(params['dealerId'])

Return anobject

Upvotes: 0

user6062970
user6062970

Reputation: 831

Looks like you’re returning an object with a property called greeting. For a webaction the response must include a property called body instead. You can nest greeting under body. See https://github.com/apache/incubator-openwhisk/blob/master/docs/webactions.md#handling-http-requests-with-actions for response requirements.

Upvotes: 7

Related Questions