Answer the question
In order to leave comments, you need to log in
Problem with getting data and json?
you need to get "records"
but the error is "Accessed JArray values with invalid key value: "datasetid". Int32 array index expected"
here is the code:
var url = @" https://data.townofcary.org/api/records/1.0/ search... ";
varweb = new WebClient();
var source = JObject.Parse(web.DownloadString(url))["records"];
var item = new
{
recordid = (string)source["recordid"],
};
var input = JObject.FromObject(item).ToString();
richTextBox1.Text = input;
Answer the question
In order to leave comments, you need to log in
Check the structure, I would recommend unpacking it into a class and proceed further.
Are you sure that you need it?
var url = @"https://data.townofcary.org/api/records/1.0/search/?dataset=railroads&q=";
var web = new WebClient();
var source = JObject.Parse(web.DownloadString(url))["records"];
var item = new
{
recordid = (string)source.First["recordid"],
};
var input = JObject.FromObject(item).ToString();
return input;
/// { "recordid": "c9b7df3efd65e8d545cc89f007988cd8c31b5465"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question