TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sunny kumar
NA
333
9.3k
Storing Api data response in database
Oct 16 2019 6:23 AM
I am able to fetch api data , but the response is coming in collection form, how should i loop through first array and store only that information . The response which i am receiving from api is as follows:
{"ngodetails":[{"id":"DL\/2017\/0165260","name":"\tASSOCIATION FOR SOCIAL SERVICE AND REHABILITATION OF THE AGED ASSRA","registrationNumber":"42540 OF 2002","panNumber":"Available","panVerifyStatus":"V"}],"memberdetails":[{"name":"NAMITA SAHOO","designation":"President","aadhaarNumber":"Available","aadhaarVerifyStatus":"V","panNumber":"Available","panVerifyStatus":"V","LastUpdated":"13-10-2017 07:00:17"},{"name":"PRASHANTA GHADAI","designation":"Vice President","aadhaarNumber":"Available","aadhaarVerifyStatus":"V","panNumber":"Available","panVerifyStatus":"V","LastUpdated":"13-10-2017 07:00:09"},{"name":"ANIL KUMAR ROY","designation":"Secretary","aadhaarNumber":"Available","aadhaarVerifyStatus":"V","panNumber":"Available","panVerifyStatus":"V","LastUpdated":"14-10-2017 11:36:20"}]}
public
ActionResult Index()
{
List<ngodarpan> ngo =
new
List<ngodarpan>();
string
baseurl =
"https://ngodarpan.gov.in/ngodarpanws_ndci/apin/getngo/DL_2017_0165260"
;
using
(var client =
new
HttpClient())
{
client.BaseAddress =
new
Uri(baseurl);
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Accept.Add(
new
System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(
"application/json"
));
HttpResponseMessage Res = client.GetAsync(baseurl).Result;
if
(Res.IsSuccessStatusCode)
{
var response = Res.Content.ReadAsStringAsync().Result;
ngo = JsonConvert.DeserializeObject<List<ngodarpan>>(response);
}
return
View(ngo);
}
}
@model IEnumerable<eofficeWepApi.Models.ngodarpan>
@{
ViewBag.Title =
"Index"
;
}
<h2>Index</h2>
<table>
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Registration Number</th>
<th>PanNumber</th>
<th>PanVerifyStatus</th>
</tr>
</thead>
<tbody>
@
foreach
(var i
in
Model)
{
<tr>
<td>@i.id</td>
<td>@i.name</td>
<td>@i.registrationnumber</td>
<td>@i.panNumber</td>
<td>@i.panVerifyStatus</td>
</tr>
}
</tbody>
</table>
Reply
Answers (
2
)
How to load DLLs into specific folder after publish
NullReferences Exception