Click here to Skip to main content
14,641,054 members

Comments by Member 14779968 (Top 26 by date)

Member 14779968 6-Aug-20 2:17am View
Yes I did. I get all the keys and values in copyOfResponseJson. I get this..
[0] {[groups, null]}
[1] {[data, Count = 100]}
[2] {[total, 110]}
Member 14779968 6-Aug-20 1:51am View
Hi Sandeep sure. I have updated the question and included the DeserializeToDictionaryOrList method
Member 14779968 5-Aug-20 14:01pm View
Hello Richard, thanks for your response.. I have updated question with one of the Json I was working with.. Please have a look.
Member 14779968 5-Aug-20 13:57pm View
Hello Garth thank you for your response.. I had updated the question and added the json I was working with..
Member 14779968 20-Jul-20 12:12pm View
Thank you so much for providing the documentation. :)
Member 14779968 18-Jul-20 22:45pm View
Updated the question.. I created a public static method writes response to the json file and also reads it and returns as a string. This is in my main base project "Project1" The "Project1" is where i am keeping my TestData.json file also. But when I use this method in "Project2" and I open the TestData.json file which is in "Project1" i have no data in it
Member 14779968 17-Jul-20 17:59pm View
Thanks for the solution. I have used the this.. but want to handle also JArray here how would I do this.. because sometimes I do get an Array of Json to check if that nested..
public static bool CheckIfJsonIsNested(IRestResponse response)
var json = response.Content;
var jObject = JObject.Parse(json);
var nested = jObject.Children().Any(x => x.Children().Any(y => y.HasValues));
if (nested)
ValidateTwoEqualJsonContent(response, json);

return nested;
Member 14779968 16-Jul-20 20:39pm View
can we write is in C#?
Member 14779968 25-Jun-20 20:45pm View
yup that did the trick Thank you :)
Member 14779968 25-Jun-20 20:10pm View
Hi Garth thanks for your response. String tokenLast = (JValue)jToken.Split('.').Last(); its giving an error saying no Split method is defined for Jtoken.

Also My main reason for the fields collector mechanism is get all the property and value from the server after hitting the API and then I want to validate a Model C# object class to it and check if the property and its value matches/contains the same as the Model.

Also Some of the API response have Array and objects or a mix.. thats why I thought maybe adding a If condition would the trick

I did something like this.. but my if condition is hard coded to check only "[0]." and I am getting many indexes
var output = RemoveBracketsandNumber(jToken.Path);
fields.Add(output, (JValue)jToken);
fields.Add(jToken.Path, (JValue)jToken); //here is where it adding from indexes"[0].id"
public static string RemoveBracketsandNumber(string str)
str = Regex.Replace(str, @"\[.+?\]", "");
str = str.Replace(".", "");
return str;
Member 14779968 25-Jun-20 17:03pm View
Yes that was my mistake. I fixed the Json.
Member 14779968 17-May-20 23:11pm View
Thank Garth. I think my main problem was to convert the response to Json when returning the HttpWebResponse. Here is the main problem I am facing trying to Convert the HttpWebReponse to Json. I opened in another question
Member 14779968 12-May-20 23:46pm View
okay I have question since I am returning the executeAPI method in another method called getResponse() which I used to get my response in my get and post call will I have to add the IRestClient instance to do my getResponse() and my GET call as well. Just wondering how will I set the client and the httpMethod when I call my doGet method since that is string

Here is my getResponse method

private static IRestResponse getResponse(string httpMethod, IRestRequest request, IRestClient client, string basePath)
return executeAPI(httpMethod, request, client, basePath);

and here is my Get method

public static IRestResponse doGet(string contentType, string baseURI, string basePath,
string token, Dictionary<string, string=""> paramsMap)
if (setBaseURI(baseURI))
IRestRequest request = sendRequest(contentType, token, paramsMap);
return getResponse("GET", request, basePath);
return null;


//Currently calling my GET Method like this
public void getAccountImageTest2()
IRestResponse response = BaseServiceCall.doGet(baseURL, basePath,token, null);
int statusCode = (int)response.StatusCode;
Assert.AreEqual(response.StatusCode, statusCode);
Member 14779968 12-May-20 22:47pm View
Thank you
Member 14779968 29-Apr-20 19:01pm View
value I have sending this a list in the body

all the API content type is application/Json
Member 14779968 4-Apr-20 22:14pm View
I agree with your comment. I went line by line and fixed the problem. Thank you OriginalGriff :)
Member 14779968 3-Apr-20 17:56pm View
Thank you that did help set the values. however I am getting
"System.NullReferenceException : Object reference not set to an instance of an object" I think its becuase the new MatchActionsReason instance? Do you how I can fix this?
Member 14779968 31-Mar-20 15:25pm View
Thanks so if I need to add all the days of the week I will just do the following right?
daysOfWeekSource = new List<daysofweeksource>
new DaysOfWeekSource
name = "Sunday",
value = 0,
isSelectedInternal = true,

new DaysOfWeekSource
name = "Monday",
value = 0,
isSelectedInternal = false

And also when I ran the test I got an Error "System.NullReferenceException : Object reference not set to an instance of an object." Its catching in return new AdminServiceTaskModel() line. Do you what might be the issue?
Member 14779968 31-Mar-20 14:55pm View
when trying to do that under the currentSchedule. It breaks the lines. I have to put it under CurrentSchedule property as that is the parent of the daysOfWeekSource if you look at the Json above
Member 14779968 31-Mar-20 14:30pm View
I am trying to access the properties here .

daysOfWeekSource = new List<daysofweeksource>
name = "Monday",
value = 1,
isSelectedInternal = true

Error: 'List<adminservicetaskmodel.daysofweeksource>' does not contain a definition of 'name'
Member 14779968 31-Mar-20 14:12pm View
this is the exact code that i am having problem with
Member 14779968 30-Mar-20 13:13pm View
I am trying to do the following validation against the Json response.

1. Validate all keys are present in the Json.
ex: If response contains id, timestamp, type, info etc.. Trying to iterate through Json to achieve this.
Member 14779968 30-Mar-20 13:02pm View
Hi Bohdan, Yes I updated the question as to what I am trying to accomplish here. I created a model class presenting the Json. But Instead of using mutiple assertions to validate every keys, I want to loop through the json and validate if all the keys are present
Member 14779968 25-Mar-20 2:16am View
So i am facing a problem assigning the values for the List. I am not sure how to do it. I have updated the question. I am not able to assign the member properties ascending and field
Member 14779968 23-Mar-20 22:10pm View
It will not let me step over the TagModel instances
Member 14779968 23-Mar-20 21:44pm View
Hi ZurdoDev my exception stackoverflow is thrown when I created the instance of the class TagModel. Its throws the error in defaultmodel instance. But how can I solve this since I need to set the values