API server: assign parameters with Request body

Hi all,
I'm trying to assign a parameter using Request body but it seems not works.
I receive this error, so I assume that the parameter used to select my response is not received:

This below is my request (taken from Failed requests):

Any suggestion?
Thank you
Claudio

Hi @clamur
Which EasyMorph Server version do you use?

There was an issue with the Request Body in the early versions of the Custom API Server. When the request body was assigned as a parameter, the request body content was removed from the IncomingHttpRequest action.
Try to use the assigned parameter directly.

Also, the error Dataset has no rows means there are no rows before the IncomingHttpRequest action.

Hi Ckononenko and thanks,
I'm using the latest, 5.6.1.
could you please explain better what you mean with "use the assigned parameter directly"?

Also, I'm not using an IncomingHTTPRequest action in my workflow, I don't know if it could be a problem.
I'm taking data from a sql table, filetring on parameter value and using ConstructHTTPresponse action. This is working with a GET request:
image

Hi Ckononenko,
I tried to add an IncomingHTTPRequest (understood that it could be skipped with a GET but needed with a POST), and now it works!
image

Another question, if I can:
Is it possible to receive an IncomingHTTP in a module, iterate with a second module and put the HTTPresponse in the second module? Or Incoming and Response must always be in a unique module?

Thank you so much
Claudio

It should be fine.

I'm taking data from a sql table, filetring on parameter value and using ConstructHTTPresponse action.

You're binding the entire request body { "ID": 105 } to the module parameter ID. You must use a ParseJson action to extract the JSON property ID from the Request Body. Only after that can you make a db query with the extracted value.

I tried to add an IncomingHTTPRequest (understood that it could be skipped with a GET but needed with a POST), and now it works!

The IncomingHTTPRequest action could be omitted with any HTTP method.

Is it possible to receive an IncomingHTTP in a module, iterate with a second module and put the HTTPresponse in the second module? Or Incoming and Response must always be in a unique module?

The ConstructHTTPResponse action is a helper action that constructs a table with specific names. The module must return a table with one row (column Response-HttpCode is required , Response-Body, and Content-Type - if a response has content) or an empty table (for NoContent response).

UPD
Also, consider splitting the logic. If db has no data (no rows), you should return the HTTP 404 Not Found.

Thank you Ckononenko!
I'll take all your suggestions and improve my flow.

Ciao
Claudio

You're welcome.
Please feel free to post questions and comments.