Click here to Skip to main content
15,891,136 members

Comments by Lupu5R3x (Top 13 by date)

Lupu5R3x 2-Apr-20 2:17am View    
That's what I did, some one told me that I could past my json as C# classes, and that save almost the same result as Afzaal's.

/LR
Lupu5R3x 31-Mar-20 9:33am View    
Afzaal's answer pointed me in the right direction, though it needed some more to work, but sins I did paste the wrong Json, my guess is that Afzaal would had thrown the right answer, so I accept his solution.
I have added the code that works below.
Lupu5R3x 30-Mar-20 7:45am View    
Hi Afzaal
I got an error using this: public class JsonObjectHolder {
public string Updates { get; set; }
public Dictionary<int, mydata=""> { get; set; }
}
But fixed it by adding a name to the Dictionary prop, public Dictionary<int, mydata=""> Dict { get; set; }

But I cant get in contact with the dictionary, I tried:
var jsonTest = JsonConvert.DeserializeObject<jsonobjectholder>(serverResponseJsonString.Result);

Console.WriteLine(jsonTest.UpdatePack);
Console.WriteLine(jsonTest.Dict.Count);

foreach (KeyValuePair<int, updateslist=""> item in jsonTest.Dict)
{
Console.WriteLine(item.Key);
}
But I get an Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at " Console.WriteLine(jsonTest.Dict.Count);", and I out comment that and tries my foreach loop I get the same error.

What Am i doing wrong?

/LR
Lupu5R3x 29-Mar-20 9:25am View    
HiI have.
When sending json I use using var stringContent = new StringContent(json, Encoding.UTF8, "application/json");
With normal post I use using (FormUrlEncodedContent content = new FormUrlEncodedContent(values)).
But it also works with StringContent and "application/x-www-form-urlencoded".

But it seems that what I want is impossible both from the server side and from the client side.

So I just send my json a post, either in urlform or as string - both seems to work.

/LR
Lupu5R3x 28-Mar-20 18:05pm View    
HiNo the post only holds the token, and the json holds the guid and versions og my program and dll's
/LR