2

when I send the post request to my Rest service it finds null values in the body. Do Anyone see what mistake it could be?

function execute_postNewUser(tempo_id, tempo_date, callback){

    // create the JSON object
     var args = {
        data : {
            'id' : tempo_id,
            'date' : tempo_date
                },
        headers : {"Content-Type": "application/json"}
    };

     console.log('JSON OBJECT ' + args.data);

     client.post('http://localhost:49952/api/values', args, function(data,response){
        console.log(data);
        console.log(response);
     });
}

Here is a capture of the powershell

Data should be the tempo_id value and the tempo_date value, but the args.data just give me [Object, Object].

The Rest service is functionnal but receives only Null data from that request.

Islena
  • 33
  • 4
  • What `client` are you using for the post request? Are you sure you are providing the args correctly? – nareddyt Jan 07 '19 at 22:51
  • I used the post example on this link https://www.npmjs.com/package/node-rest-client I installed the npm package to get the last version. args should be ok. – Islena Jan 08 '19 at 09:09
  • By the way, to properly log the object (instead of just seeing `[Object, Object]`), see [this SO post](https://stackoverflow.com/a/4293047/4402434). I believe `args.data` is correct though, so that shouldn't be an issue. – nareddyt Jan 08 '19 at 19:11
  • Perhaps this is an issue with your REST service. Have you tried using a tool like Postman to post the same data to it? – nareddyt Jan 08 '19 at 19:11
  • I achieved to get the correct data in the log, but the problem lasts. I'll go see what Postman is, and what i can find in the Rest part. – Islena Jan 10 '19 at 18:41
  • Can you send the declaration of the method from your REST, as well a the class declaration you are trying to parse ? – Augustin Bocken Jan 19 '19 at 10:41

0 Answers0