# Can't call API by dynatrace but succeed with postman

**URL:** <https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140>\
**Category:** Open Q&A\
**Tags:** dynatrace-api\
**Created:** [October 18, 2023, 2:12am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140 "2023-10-18T02:12:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quirina](https://avatars.discourse-cdn.com/v4/letter/q/8797f3/32.png) [@Quirina](https://community.dynatrace.com/u/Quirina)\
**Post date:** [October 18, 2023, 2:12am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140/1 "2023-10-18T02:12:39Z")

</div>

Hi Team, We’re planning to use dynatrace to do the API monitoring. I’m facing one issue - I’m able to call one API successfully with postman but failed with Dynatrace. Request url and http hearder and requestbody are all same.&nbsp; But I got error all the time from dynatrace. I checked the error as below:

 ![Quirina_0-1697594958349.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/f/8f6b64480c7db17a7b8b5a30bbde7c98e75d8bb7.png)

The script setting as below:

 ![Quirina_1-1697595071988.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/e/6e3654903a68f4a513067d174013629092625854.png)

Could anyone help to check why it often fail, please?

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [October 18, 2023, 6:36am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140/2 "2023-10-18T06:36:24Z")

</div>

Hi,

You can see an entry about [Troubleshooting HTTP Monitor Error/ Health Status Codes](https://community.dynatrace.com/post/218180).

Are you sure header and payload in body are correct?

Best regards

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [October 18, 2023, 7:13am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140/3 "2023-10-18T07:13:31Z")

</div>

Hi,

You are given the wrong Service name.

In the first step, use the API ([GET entities list](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/entity-v2/get-entities-list?_ga=2.31375679.1688602524.1697440282-6151948.1694588859&_gac=1.121583994.1697549154.Cj0KCQjw4bipBhCyARIsAFsieCzZ7eDSuTu3xQqyEYVhCUY5E4rk5ipWZ1AUDoWEvu9lR2HUjXyz5kYaAgaDEALw_wcB&_gl=1*1sdpeb7*_ga*NjE1MTk0OC4xNjk0NTg4ODU5*_ga_1MEMV02JXV*MTY5NzYxMjc5MS43NC4xLjE2OTc2MTI5ODcuMC4wLjA.)) to retrieve the list of services. Then use the name (entityId) of the service you want to use using the name that was returned after the API (it differs slightly from what you see in the GUI)

Example:

curl -L -X GET ‘[https://mySampleEnv.live.dynatrace.com/api/v2/entities?entitySelector=type(“SERVICE”),mzId(“9130632296508575249”)&fields=lastSeenTms,properties.serviceTechnologyTypes](https://mySampleEnv.live.dynatrace.com/api/v2/entities?entitySelector=type(%22SERVICE%22),mzId(%229130632296508575249%22)&fields=lastSeenTms,properties.serviceTechnologyTypes)’ \  
-H ‘Authorization: Api-Token xxx’

{ “totalCount”: 52, “pageSize”: 50, “nextPageKey”: “AQArdHlwZSgiU0VSVklDRSIpL”, “entities”: [{ " **entityId"**** : “SERVICE-1125C375A187D27A”**,“displayName”: “dotNetBackend\_easyTravel\_x64”, “lastSeenTms”: 1590609632865, “properties”: { “serviceTechnologyTypes”: [ “IIS app pool”, “[ASP.NET](http://ASP.NET)”, “DotNet” ] } },

Radek

---

<div class="post-metadata">

**Author:** ![Quirina](https://avatars.discourse-cdn.com/v4/letter/q/8797f3/32.png) [@Quirina](https://community.dynatrace.com/u/Quirina)\
**Post date:** [October 19, 2023, 1:05am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140/4 "2023-10-19T01:05:01Z")

</div>

I checked the headers and found the root cause is due to lack of one header. Thank you so much for the reminder!!

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [October 19, 2023, 6:51am UTC](https://community.dynatrace.com/t/cant-call-api-by-dynatrace-but-succeed-with-postman/42140/5 "2023-10-19T06:51:34Z")

</div>

Perfect and welcome!&nbsp;😎
