consuldotnet icon indicating copy to clipboard operation
consuldotnet copied to clipboard

Status Code always 0

Open Wesam18 opened this issue 10 years ago • 4 comments

Checking the status code of the k/v get response always return 0.

    var getPair = await client.KV.Get(key, setting);
    if (getPair.StatusCode == System.Net.HttpStatusCode.OK) // Alaways fail 
    {
       var value = Encoding.UTF8.GetString(getPair.Response.Value, 0, getPair.Response.Value.Length));
         }

Wesam18 avatar Mar 19 '16 21:03 Wesam18

I'm able to replicate this, and wow, this is a weird one. If I look at the debugger inside Client.cs for GetRequest.Execute I see the "OK" as the statuscode but if I look at it from outside the Execute method it shows 0. Investigating, thank you for the report.

highlyunavailable avatar Mar 19 '16 23:03 highlyunavailable

Oh, I know why - I have to reconstruct an object for KVPairs specifically and I'm not copying a field. This should be a quick fix.

highlyunavailable avatar Mar 19 '16 23:03 highlyunavailable

This should be resolved as of 0.6.4.0 which is available on Nuget: https://www.nuget.org/packages/Consul

Have fun!

highlyunavailable avatar Mar 20 '16 00:03 highlyunavailable

Thank you @highlyunavailable for your quick response.

Wesam18 avatar Mar 20 '16 02:03 Wesam18