Cannot read attribute of type Datetime in View
up vote
0
down vote
favorite
I am trying to display a json array which I got from consuming a web service that returns a list of resourceRequests that contain an attribute 'dateDepot' of type DateTime but it doesn't work unlike type Date
it works fine
My entity :
public class ResourceRequestViewModel
{
[Key]
public int requestId { get; set; }
[StringLength(255)]
public string Director { get; set; }
[StringLength(255)]
public string EducationScolarity { get; set; }
[StringLength(255)]
public string Title { get; set; }
public DateTime depotDate { get; set; }
}
My view :
@foreach (var item in ViewBag.result)
{
<tr>
<td>
@item.requestId
</td>
<td>
@item.Director
</td>
<td>
@item.depotDate
</td>
</tr>
}
My controller :
public ActionResult Index()
{
List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
}
else
{
ViewBag.result ="ERRORRR";
}
return View();
}
My Json output from the web service :
[
{
"requestId": 1,
"client": {
"id": 1,
"nom": null,
"ipAdress": null,
"logo": null,
"categorie": "client_prive",
"typeClient": "nouveau_client",
"etat": null
},
"listMandats": ,
"director": "Fadi Ben nejma",
"title": "Title1",
"educationScolarity": "Uni",
"depotDate": 1541026800000,
"depotHour": 12,
"mandateStartDate": "2018-10-30",
"mandateEndDate": null,
"requiremenets": "php angular html",
"searchedProfile": "Backend Developper",
"yearsOfExperience": 5,
"EducationScolarity": "Uni",
"project": {
"id": 1,
"statut": "projet_encours",
"name": "slim",
"nom": "aouadi",
"etat": "1",
"projetStartDate": "2018-10-01",
"projetEndDate": "2018-10-31"
},
"Director": "Fadi Ben nejma"
}
]
The error I get is :
Error reading date. Unexpected token: Integer. Path '[0].depotDate'
c# asp.net-mvc visual-studio
|
show 2 more comments
up vote
0
down vote
favorite
I am trying to display a json array which I got from consuming a web service that returns a list of resourceRequests that contain an attribute 'dateDepot' of type DateTime but it doesn't work unlike type Date
it works fine
My entity :
public class ResourceRequestViewModel
{
[Key]
public int requestId { get; set; }
[StringLength(255)]
public string Director { get; set; }
[StringLength(255)]
public string EducationScolarity { get; set; }
[StringLength(255)]
public string Title { get; set; }
public DateTime depotDate { get; set; }
}
My view :
@foreach (var item in ViewBag.result)
{
<tr>
<td>
@item.requestId
</td>
<td>
@item.Director
</td>
<td>
@item.depotDate
</td>
</tr>
}
My controller :
public ActionResult Index()
{
List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
}
else
{
ViewBag.result ="ERRORRR";
}
return View();
}
My Json output from the web service :
[
{
"requestId": 1,
"client": {
"id": 1,
"nom": null,
"ipAdress": null,
"logo": null,
"categorie": "client_prive",
"typeClient": "nouveau_client",
"etat": null
},
"listMandats": ,
"director": "Fadi Ben nejma",
"title": "Title1",
"educationScolarity": "Uni",
"depotDate": 1541026800000,
"depotHour": 12,
"mandateStartDate": "2018-10-30",
"mandateEndDate": null,
"requiremenets": "php angular html",
"searchedProfile": "Backend Developper",
"yearsOfExperience": 5,
"EducationScolarity": "Uni",
"project": {
"id": 1,
"statut": "projet_encours",
"name": "slim",
"nom": "aouadi",
"etat": "1",
"projetStartDate": "2018-10-01",
"projetEndDate": "2018-10-31"
},
"Director": "Fadi Ben nejma"
}
]
The error I get is :
Error reading date. Unexpected token: Integer. Path '[0].depotDate'
c# asp.net-mvc visual-studio
Can you show us the code in your controller that setsViewBag.result
?
– Gabriel Luci
Nov 11 at 21:08
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
1
It doesn't understand that date format:"depotDate": 1541026800000
. What type of date is that?
– Gabriel Luci
Nov 11 at 21:19
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26
|
show 2 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to display a json array which I got from consuming a web service that returns a list of resourceRequests that contain an attribute 'dateDepot' of type DateTime but it doesn't work unlike type Date
it works fine
My entity :
public class ResourceRequestViewModel
{
[Key]
public int requestId { get; set; }
[StringLength(255)]
public string Director { get; set; }
[StringLength(255)]
public string EducationScolarity { get; set; }
[StringLength(255)]
public string Title { get; set; }
public DateTime depotDate { get; set; }
}
My view :
@foreach (var item in ViewBag.result)
{
<tr>
<td>
@item.requestId
</td>
<td>
@item.Director
</td>
<td>
@item.depotDate
</td>
</tr>
}
My controller :
public ActionResult Index()
{
List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
}
else
{
ViewBag.result ="ERRORRR";
}
return View();
}
My Json output from the web service :
[
{
"requestId": 1,
"client": {
"id": 1,
"nom": null,
"ipAdress": null,
"logo": null,
"categorie": "client_prive",
"typeClient": "nouveau_client",
"etat": null
},
"listMandats": ,
"director": "Fadi Ben nejma",
"title": "Title1",
"educationScolarity": "Uni",
"depotDate": 1541026800000,
"depotHour": 12,
"mandateStartDate": "2018-10-30",
"mandateEndDate": null,
"requiremenets": "php angular html",
"searchedProfile": "Backend Developper",
"yearsOfExperience": 5,
"EducationScolarity": "Uni",
"project": {
"id": 1,
"statut": "projet_encours",
"name": "slim",
"nom": "aouadi",
"etat": "1",
"projetStartDate": "2018-10-01",
"projetEndDate": "2018-10-31"
},
"Director": "Fadi Ben nejma"
}
]
The error I get is :
Error reading date. Unexpected token: Integer. Path '[0].depotDate'
c# asp.net-mvc visual-studio
I am trying to display a json array which I got from consuming a web service that returns a list of resourceRequests that contain an attribute 'dateDepot' of type DateTime but it doesn't work unlike type Date
it works fine
My entity :
public class ResourceRequestViewModel
{
[Key]
public int requestId { get; set; }
[StringLength(255)]
public string Director { get; set; }
[StringLength(255)]
public string EducationScolarity { get; set; }
[StringLength(255)]
public string Title { get; set; }
public DateTime depotDate { get; set; }
}
My view :
@foreach (var item in ViewBag.result)
{
<tr>
<td>
@item.requestId
</td>
<td>
@item.Director
</td>
<td>
@item.depotDate
</td>
</tr>
}
My controller :
public ActionResult Index()
{
List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
}
else
{
ViewBag.result ="ERRORRR";
}
return View();
}
My Json output from the web service :
[
{
"requestId": 1,
"client": {
"id": 1,
"nom": null,
"ipAdress": null,
"logo": null,
"categorie": "client_prive",
"typeClient": "nouveau_client",
"etat": null
},
"listMandats": ,
"director": "Fadi Ben nejma",
"title": "Title1",
"educationScolarity": "Uni",
"depotDate": 1541026800000,
"depotHour": 12,
"mandateStartDate": "2018-10-30",
"mandateEndDate": null,
"requiremenets": "php angular html",
"searchedProfile": "Backend Developper",
"yearsOfExperience": 5,
"EducationScolarity": "Uni",
"project": {
"id": 1,
"statut": "projet_encours",
"name": "slim",
"nom": "aouadi",
"etat": "1",
"projetStartDate": "2018-10-01",
"projetEndDate": "2018-10-31"
},
"Director": "Fadi Ben nejma"
}
]
The error I get is :
Error reading date. Unexpected token: Integer. Path '[0].depotDate'
c# asp.net-mvc visual-studio
c# asp.net-mvc visual-studio
edited Nov 11 at 21:55
marc_s
568k12810991249
568k12810991249
asked Nov 11 at 21:04
AOUADI Slim
6810
6810
Can you show us the code in your controller that setsViewBag.result
?
– Gabriel Luci
Nov 11 at 21:08
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
1
It doesn't understand that date format:"depotDate": 1541026800000
. What type of date is that?
– Gabriel Luci
Nov 11 at 21:19
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26
|
show 2 more comments
Can you show us the code in your controller that setsViewBag.result
?
– Gabriel Luci
Nov 11 at 21:08
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
1
It doesn't understand that date format:"depotDate": 1541026800000
. What type of date is that?
– Gabriel Luci
Nov 11 at 21:19
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26
Can you show us the code in your controller that sets
ViewBag.result
?– Gabriel Luci
Nov 11 at 21:08
Can you show us the code in your controller that sets
ViewBag.result
?– Gabriel Luci
Nov 11 at 21:08
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
1
1
It doesn't understand that date format:
"depotDate": 1541026800000
. What type of date is that?– Gabriel Luci
Nov 11 at 21:19
It doesn't understand that date format:
"depotDate": 1541026800000
. What type of date is that?– Gabriel Luci
Nov 11 at 21:19
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26
|
show 2 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53253224%2fcannot-read-attribute-of-type-datetime-in-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show us the code in your controller that sets
ViewBag.result
?– Gabriel Luci
Nov 11 at 21:08
@GabrielLuci it's done
– AOUADI Slim
Nov 11 at 21:13
1
It doesn't understand that date format:
"depotDate": 1541026800000
. What type of date is that?– Gabriel Luci
Nov 11 at 21:19
@Temporal(TemporalType.TIMESTAMP)
– AOUADI Slim
Nov 11 at 21:21
Do you control the app that creates that JSON? If so, you can probably change how that is serialized into JSON so it's a more standard date format.
– Gabriel Luci
Nov 11 at 21:26