-1

When I am running below send request from Postman - Tests, getting 400 bad request. Could anyone tell me where I am wrong in sending the request?

let loginRequest = {
        url: new_url,
        method: 'POST',
        headers: {
            "Content-Type": "application/json",
            "Authorization":autho
        },
        body: { 
            mode: 'raw',
            raw:JSON.stringify({
                "name":child_group,
                "description":"Create Via RestAPI"
            })}  
    };
    // send request 
        pm.sendRequest(loginRequest, function (err, res) {
            console.log(err ? err : res.text());
        });

Error: { "message" : "Missing Authorization header."}

1 Answers1

0

@Manish Katepallewar , this worked for me:

let loginRequest=
{
 url:new_url,
 method:'post',
 header:
 {
  'Content-Type':'application/json',
  'Authorization':autho
 },
 body:
 { 
  mode:'raw',
  raw:JSON.stringify(
  {
   'name':child_group,
   'description':'Create Via RestAPI'
  })
 }  
};

pm.sendRequest(loginRequest,function(err,res)
{
 console.log(err?err:res.text());
});
sanepete
  • 979
  • 9
  • 28