fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
380 stars 182 forks source link

Adding return type to the Generic Post #77

Closed Timothyoverton closed 8 years ago

Timothyoverton commented 8 years ago

For my API, I'm returning a string with important information.

With this change I can do the following:

FErrorMessage := RestClient.Resource(restUrl)

                              .Accept(RestUtils.MediaType_Json)

                              .ContentType(RestUtils.MediaType_Json)

                              .Post<TPdfMergeDto, string>(MergeDto);
RobertoSchneiders commented 8 years ago

Thank for contributing @Timothyoverton, but I really don't understand the use case for this. Can you explain it?

As far as I can see, you could simply have used something like this:

FErrorMessage := RestClient.Resource(restUrl)
                  .Accept(RestUtils.MediaType_Json)
                  .ContentType(RestUtils.MediaType_Json)
                  .Post<string>(MergeDto);

In your code you are not using the first generic param <T> anywhere.

Timothyoverton commented 8 years ago

Hi Roberto,

I did receive a Marshalling error when I first tried post(MergeDTO), I thought the type was required to serialize the object. My mistake, all is working well now. I'll cancel this PR.

Thanks