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
I'm trying to deserialise a Text/Plain response, however, found the JSON is the default. I've created the following but doesn't feel right, Isn't there an easier way? Moreover, it would be great in addition to JsonResponseDeserializer if there were more pre-made deserializer classes to pick from.
public override T Deserialize<T>(string content, HttpResponseMessage response, ResponseDeserializerInfo info)
{
if(typeof(string).IsAssignableFrom(typeof(T)))
{
return (T)(object)content;
}
throw new InvalidDataException("Plain Text response deserializer can only be used with string");
}
The text was updated successfully, but these errors were encountered:
Instead I have Task<Response<string>> decorated with [AllowAnyStatusCode] As I need granular control over the response as I need to act on different Status Codes.
i.e.
if (response.ResponseMessage.StatusCode == HttpStatusCode.Unauthorized)...
My proposed solution has worked above but good to know if there is another way.
Task<Response<string>> Does fail using the default JSON deserializer
I'm trying to deserialise a Text/Plain response, however, found the JSON is the default. I've created the following but doesn't feel right, Isn't there an easier way? Moreover, it would be great in addition to JsonResponseDeserializer if there were more pre-made deserializer classes to pick from.
The text was updated successfully, but these errors were encountered: