HttpResponseMessage caching using redis

34 Views Asked by At

i want to get HttpResponseMessage from redis cache using dapr.

HttpResponseMessage doesn't any public constructor so I got error while casting json to HttpResponseMessage.

How can I save HttpResponseMessage object into redis and how can I get ?

Save operation:

HttpResponseMessage value = await MakeApiRequestCore(httpClient,callMethod,requestUri,accessToken,timeout,isResponseHttpResponseMessage, cancellationToken);
               
await _daprClient.SaveStateAsync<HttpResponseMessage>(redisStoreName, cacheKey, value, null, metadata, cancellationToken);

Get operation: (Error: System.NotSupportedException: Deserialization of types without a parameterless constructor, a singular parameterized constructor, or a parameterized constructor annotated with 'JsonConstructorAttribute' is not supported. Type 'System.Net.Http.HttpContent'. Path: $.content | LineNumber: 0 | BytePositionInLine: 28)

 var value = await _daprClient.GetStateAsync<HttpResponseMessage>(redisStoreName, cacheKey, cancellationToken: cancellationToken);
0

There are 0 best solutions below