JSONServiceClient doesnt support base64 result


I’m using ServiceStack 5.7 to create and access my API. At one request I return a base64 encoded string.

[AddHeader(ContentType = "image/png")]
[AddHeader(ContentEncoding = "base64")]
public string Get(GetConsumerShowAssetThumbnail request)
    Guard.Against.NullOrEmpty(request.ShowLinkUUID, nameof(request.ShowLinkUUID));
    Guard.Against.InvalidObjectId(request.AssetId, nameof(request.AssetId));

    return Convert.ToBase64String(BOS.GetAssetThumbnailData(request.ShowLinkUUID, request.AssetId));

now my JsonServiceClient tells me that it can’t handle base64 encoded content (NotSupportedException).

Is that correct? How can I handle base64 encoded streams?

kind regards

No it doesn’t, Content-Encoding is only supported for compressed responses. If you want to return a base64 string, just return the string (i.e. without any Encoding, string’s are already returned as text/plain):

class GetConsumerShowAssetThumbnail : IReturn<string> { ... }

public string Get(GetConsumerShowAssetThumbnail request) => 

But don’t return base64 encoded text for binary data like images, ServiceStack supports returning raw data types so just return the raw bytes to avoid unnecessary encoding/decoding perf overhead and bloated payloads:

[AddHeader(ContentType = "image/png")]
public byte[] Get(GetConsumerShowAssetThumbnail request)
    return BOS.GetAssetThumbnailData(request.ShowLinkUUID, request.AssetId);

Allright, thanks for clarification