1

Usually I send my post request with a custom parameter and a custom return and object using

HttpClientExtension.PostAsJsonAsync<T>

This allows my to call a post method with a custom object.

Now, I want to be able to send my custom object as a parameter and return value to a GET Method.
Lets say my method signature is

[HttpGet]
public MyMethodResponse MyMethod(MyMethodRequest request)  

How can I send a request when I have an instance of MyMethodRequest ?
Thanks.

1 Answer 1

2

You need to encode MyMethodRequest onto the query string. You can either encode it as separate query string parameters or as a single one. You have handle the encoding yourself on the client side, remembering to URI-encode the parameters. Decoding is done using a custom ModelBinder or TypeConverter respectively. This article shows examples of binding a complex object on the query string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.