Xdata read x-www-form-urlencoded parameters

Hi,

I would like to read params in an xdata server using x-www-form-urlencoded. The data can be retrieved via context.Request.ContentStream.

However, in the changelog (https://doc.tmssoftware.com/biz/xdata/xdata-user-guide.pdf) is stated:

"Consumes attribute allows receiving parameters as x-www-form-urlencoded
typ"

Which assumes that there is an easier way to retrieve compared to directly reading from the contentstream.

Is that true? And if so, how can I achieve this?

Thank you.

Yes, that's correct. You can declare a method like this:

    [Consumes('application/x-www-form-urlencoded')]
    function SumForm(A, B: double): ResultFloatType;

And XData will automatically deserialize A and B from the x-www-form-urlencoded content.

You can also use DTO classes and XData will automatically deserialize them as well, as long as the class only has fields and properties of primitive types, not structured ones (arrays/objects).

1 Like

Thank you. Works as expected.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.