# Can't get response after use pm.sendrequest

**URL:** <https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479>\
**Category:** Help Hub\
**Created:** [August 22, 2018, 11:34am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479 "2018-08-22T11:34:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![p.zhou](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@p.zhou](https://community.postman.com/u/p.zhou)\
**Post date:** [August 22, 2018, 11:34am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/1 "2018-08-22T11:34:37Z")

</div>

hi，

i hava used this script codes in tests following doc,but can’t get the response;

i hava confirmed from log that it send correct request ,but no response;

pls help me;thk;

const postRequest = {  
url: ‘\*\*\*’,  
method: ‘POST’,  
header: ‘headername1:value1’,  
body: {  
mode: ‘raw’,  
raw: JSON.stringify({ deviceid: ‘280494’ })  
}  
};

```
pm.sendRequest(postRequest,function(err,res){
    tests["res:"]=true;
    tests["res:"+err?err:res.json()]=true;
});
```

---

<div class="post-metadata">

**Author:** ![tkloeber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/tkloeber/32/8884_2.png) [@tkloeber](https://community.postman.com/u/tkloeber)\
**Post date:** [August 23, 2018, 8:51am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/2 "2018-08-23T08:51:22Z")

</div>

did you try setting the content type in your header to json?

---

<div class="post-metadata">

**Author:** ![p.zhou](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@p.zhou](https://community.postman.com/u/p.zhou)\
**Post date:** [August 23, 2018, 9:07am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/3 "2018-08-23T09:07:30Z")

</div>

yes,i hava set the content value in header,like this:

const postRequest = {  
url: ‘**’,  
method: ‘POST’,  
header: {  
‘content-type’: ‘application/json’  
},  
body: {  
mode: ‘raw’,  
raw: JSON.stringify({ deviceid: '**’ })  
}  
};

but i hava not get any debug log after running. i don’t know why can’t get response if use scrpit;  
pls help me, thanks;

---

<div class="post-metadata">

**Author:** ![tkloeber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/tkloeber/32/8884_2.png) [@tkloeber](https://community.postman.com/u/tkloeber)\
**Post date:** [August 23, 2018, 9:11am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/4 "2018-08-23T09:11:41Z")

</div>

try ‘Content-Type’, headers are case sensitive (sometimes, I think ;))

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [August 23, 2018, 9:15am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/5 "2018-08-23T09:15:59Z")

</div>

Hi @p.zhou  
Here’s a collection that you can import and run and test out:  
[https://www.getpostman.com/collections/41d8091fbc21b1e94480](https://www.getpostman.com/collections/41d8091fbc21b1e94480)

You definitely need proper headers as mentioned in the above comments by @tkloeber

Also, your request is being ran just that you don’t see it in the UI.  
You can open the Postman Console and test it out.

Using the old syntax of writing tests ‘tests’ like `tests['this wont work'] = true` will not work with the pm.sendRequest api’s.

It’s highly advised that you use the new syntax of writing tests which is like so:  
`pm.test('Hey this is a good way to write tests', function () {...})`  
and make use of the pm api’s.

Sandbox Reference: [https://www.getpostman.com/docs/v6/postman/scripts/postman\_sandbox\_api\_reference](https://www.getpostman.com/docs/v6/postman/scripts/postman_sandbox_api_reference)

---

<div class="post-metadata">

**Author:** ![p.zhou](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@p.zhou](https://community.postman.com/u/p.zhou)\
**Post date:** [August 23, 2018, 9:32am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/6 "2018-08-23T09:32:19Z")

</div>

yes,your method was correct that use pm.test can get the response.

thank you very much.

---

<div class="post-metadata">

**Author:** ![singhsivcan](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/singhsivcan/32/1595_2.png) [@singhsivcan](https://community.postman.com/u/singhsivcan)\
**Post date:** [August 23, 2018, 9:56am UTC](https://community.postman.com/t/cant-get-response-after-use-pm-sendrequest/2479/7 "2018-08-23T09:56:27Z")

</div>

Most welcome, sir! 😃
