You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, what if there is no response? ApiResponse (without type) is internal and cannot be used. I suppose technically there's always some content response (in the form of an empty string), but I think it'd be silly to have to define my endpoint/contract as "this returns a string" when one is never returned. So for now, my workaround is this:
[Post("/foo")]publicTask<ApiResponse<string>>Foo(RequestBodyrequest,CancellationTokencancellationToken);// the string is always empty, but users of this client won't know that!
Is there a way to use ApiResponse so I can check the status code, ensure success, etc. without having to provide a type?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello. I have a simple scenario: Hit an endpoint that returns nothing, but be able to inspect the response code/etc.
If I didn't care about the response I'd do something like:
And if the HTTP hit returned some response, I'd model it with
ApiResponse<T>
:However, what if there is no response?
ApiResponse
(without type) is internal and cannot be used. I suppose technically there's always some content response (in the form of an empty string), but I think it'd be silly to have to define my endpoint/contract as "this returns a string" when one is never returned. So for now, my workaround is this:Is there a way to use
ApiResponse
so I can check the status code, ensure success, etc. without having to provide a type?Beta Was this translation helpful? Give feedback.
All reactions