0
Hi, I’m calling a web service in Rest, I can access the answer but I wanted to organize the data that is returned (which is in Json), for an array or variables but how can I do it? Thank you in advance.
public async Task<string> Get()
{
try
{
string errorMessage;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("******", "************");
client.GetType();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync(EndPoint);
if (response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsAsync<ExpandoObject>();
var _dataResponse = JToken.Parse(JsonConvert.SerializeObject(data));
var daraMember = _dataResponse["member"]["href"];
}
client.Dispose();
}
catch(Exception ex)
{
errorMessage= ex.Message;
}
I wanted to get this information:
{"member": [{
"href": "aquamandev.adp.pt/maximo/oslc/os/zwssr/_U1IvMTAwMDYwNQ--"}],
"href": "aquamandev.adp.pt/maximo/oslc/os/zwssr",
"responseInfo":
{ "totalPages": 1,
"href": "aquamandev.adp.pt/maximo/oslc/os/…",
"totalCount": 1,
"pagenum": 1 }
}
you want to consume the data from that webservice?
– Amadeu Antunes
@Amadeuantunes yes and put in an array follows what web service returns in json, I’ll ask the question
– Diogo Gomes