# Response assertion error on pm.sendRequest

**URL:** <https://community.postman.com/t/response-assertion-error-on-pm-sendrequest/47183>\
**Category:** Help Hub\
**Tags:** sendrequest\
**Created:** [May 7, 2023, 7:32am UTC](https://community.postman.com/t/response-assertion-error-on-pm-sendrequest/47183 "2023-05-07T07:32:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![inisalamadu](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@inisalamadu](https://community.postman.com/u/inisalamadu)\
**Post date:** [May 7, 2023, 7:32am UTC](https://community.postman.com/t/response-assertion-error-on-pm-sendrequest/47183/1 "2023-05-07T07:32:42Z")

</div>

```auto
pm.test("Driver:Password Rest: Reset driver password with proper data", function () {
    var jsonData = pm.response.json();
    pm.expect(jsonData.message).eq("Password rest successfully done!");
});

//Now we need to try if the changed password work
pm.test("Driver:Password Rest: re-login and check if the password reset been successful", function () {
    var jsonData = pm.response.json();

        pm.sendRequest({
            method: 'POST',
            url: pm.environment.get('url') + '/driver/login?',
            header: {
                'Authorization': 'Basic ' + btoa(pm.variables.get('driver_email') + ":" + pm.variables.get('newPassword')),
            }
        },function(err,res){
             pm.expect(parseInt(res.code)).eq(400);
        });
        
});

```

I have the above code, but on the last test case, the response says 200. This fails with “AssertionError: expected 200 to equal 400”. cause to fail everything even if the report is not get generated. But if the expected values match, then it shows a pass test case in the report too. how can I fix this

---

<div class="post-metadata">

**Author:** ![inisalamadu](https://avatars.discourse-cdn.com/v4/letter/i/3e96dc/32.png) [@inisalamadu](https://community.postman.com/u/inisalamadu)\
**Post date:** [May 7, 2023, 7:40am UTC](https://community.postman.com/t/response-assertion-error-on-pm-sendrequest/47183/2 "2023-05-07T07:40:28Z")

</div>

after so, many attempts i just figured this just after post the question in here.  
We just need to do last test case in other way around

```auto
pm.sendRequest({
            method: 'POST',
            url: pm.environment.get('url') + '/driver/login?',
            header: {
                'Authorization': 'Basic ' + btoa(pm.variables.get('driver_email') + ":" + pm.variables.get('newPassword')),
            }
        },function(err,res){
            pm.test("Driver:Password Rest: re-login and check if the password reset been successful", function () {
                //var jsonData = pm.response.json();
                pm.expect(parseInt(res.code)).eq(200);
            });
        });

```

> <https://stackoverflow.com/questions/51741745/how-to-get-expected-and-actual-result-on-console-when-a-test-fails-in-postman/51744688#51744688>
