2

Hello I have an application that creates an object which holds a Date variable. The object is then passed into an http update function. Unfortunately, the update when it goes through everything looks great except the date is reset to 2018-06-06T04:00:00 instead of the actual time that was added. for testing purposes I ran the update query separately with the same object payload and it went through fine so I know is not the api. Any ideas what I could be doing wrong?

item in JSON used for payload:

{"id":10, "name":"test", "description":"test description", "startDate":"2018-06-06T23:30:00.000Z", "endDate":"2018-06-07T02:30:00.000Z"}

Code:

app.config(function($routeProvider, $resourceProvider, $httpProvider) {   
    $httpProvider.defaults.headers.common = {Accept: "application/json, text/plain, */*"};

  //other code to set up routes, also added an interceptor to verify the data been sent, this is where I was able to see the data's Date time is reset.

});



//function to update

function updateObj(item){
    $http.put(urlToApi, item, {headers:{'Content-Type': 'application/json', 'Accept': 'application/json'}})
    .then(function successCallback(response) {
      console.log(response);
     }, function errorCallback(response) {
       console.log("ERROR: " + response);
     });
}
paul590
  • 1,385
  • 1
  • 22
  • 43
  • 1
    When you say that you have tested with same payload, do you mean the same payload and same way i.e. $http.put() ? – PM. Jun 06 '18 at 01:32
  • @PM. sorry for being vague, yes, I copied the json object from the console of my application and pasted it in Jmeter, with the same headers api url and put method and it worked with no problems – paul590 Jun 06 '18 at 01:34
  • 1
    Can you paste your item object in your question? – PM. Jun 06 '18 at 01:40
  • @PM. sure thing I updated my question above with this info – paul590 Jun 06 '18 at 01:47
  • That's weird, everything looks good. Should work! – PM. Jun 06 '18 at 23:00

0 Answers0