# Get all entities giving me error

**URL:** <https://community.dynatrace.com/t/get-all-entities-giving-me-error/37372>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [November 21, 2022, 4:49am UTC](https://community.dynatrace.com/t/get-all-entities-giving-me-error/37372 "2022-11-21T04:49:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurulakshman](https://avatars.discourse-cdn.com/v4/letter/g/c37758/32.png) [@gurulakshman](https://community.dynatrace.com/u/gurulakshman)\
**Post date:** [November 21, 2022, 4:49am UTC](https://community.dynatrace.com/t/get-all-entities-giving-me-error/37372/1 "2022-11-21T04:49:04Z")

</div>

I am trying to get all entities using this api call

https://{your-environment-id}.live.dynatrace.com/api/v2/entities

Let me know why i am getting this error

But this gives me error

{“error”: {“code”: 400,“message”: “Constraints violated.”,“constraintViolations”: [{“path”: “entitySelector”,“message”: “must be set if next-page-key is not defined”,“parameterLocation”: “QUERY”,“location”: null}]}}

---

<div class="post-metadata">

**Author:** ![dt\_martin](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dt\_martin](https://community.dynatrace.com/u/dt_martin)\
**Post date:** [November 21, 2022, 11:54am UTC](https://community.dynatrace.com/t/get-all-entities-giving-me-error/37372/2 "2022-11-21T11:54:55Z")

</div>

Doing this in one API call is not possible as you must specify the entitySelector parameter for this API call, if you do not have a next-page-key defined.

Getting all entities would require you to first query all possible types with  
https://{your-environment-id}.live.dynatrace.com/api/v2/entityTypes

and query https://{your-environment-id}.live.dynatrace.com/api/v2/entities?entitySelector=type(“your-type”) with each type you get back from the entityTypes endpoint.

For reference:

> **[Monitored entities API - GET all entity types](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/entity-v2/get-all-entity-types)**
>
> View all types of monitored entities in your environment via Dynatrace API.

> **[Environment API v2 - Entity selector](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/entity-v2/entity-selector)**
>
> Learn the Environment API v2 entity selector syntax for filtering monitored entities by type, name, tag, management zone, and health state.
