Skip to content

A POST wihtout specifying a body #1630

Answered by EDMPhoenix
Ilia-Kosenkov asked this question in Q&A
Discussion options

You must be logged in to vote

Refit, by design, automatically serializes the first argument of a POST method to JSON and assigns it to the request body when no parameter is explicitly set with [Body] attribute. This is why you're seeing the "string-content" in the body when Refit makes the request.

If you don't want any body in your request, your current solution of adding a [Body] NoBody noBody parameter is good. Another way is to pass it as a null argument, like you mentioned.

The issue isn't explicitly documented because it's part of the automagic that makes Refit easy to use in most common cases.

I hope that answers your question. Don't hesitate to ask if you have any more doubts.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Ilia-Kosenkov
Comment options

@EDMPhoenix
Comment options

Answer selected by Ilia-Kosenkov
@Ilia-Kosenkov
Comment options

@EDMPhoenix
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants