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'











share|improve this question
























  • 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















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'











share|improve this question
























  • 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













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'











share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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
















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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Bressuire

Vorschmack

Quarantine