# Error creating Reflection using Rest API

**URL:** <https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356>\
**Category:** Uncategorized\
**Created:** [December 3, 2018, 1:55pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356 "2018-12-03T13:55:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monika\_Goel](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Monika\_Goel](https://community.dremio.com/u/Monika_Goel)\
**Post date:** [December 3, 2018, 1:55pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356/1 "2018-12-03T13:55:43Z")

</div>

Hi Team,

I am trying to create Reflection using Rest API but it fails with error ‘datasetId must reference an existing dataset’. While dataset already exists in dremio, tried with Physical & Virtual dataset but same error.

Can you please provide any insight in this?

Thanks.

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [December 3, 2018, 3:41pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356/2 "2018-12-03T15:41:54Z")

</div>

Can you post the way you’ve tried to implement this so we can suggest what should change?

---

<div class="post-metadata">

**Author:** ![doron](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/doron/32/294_2.png) [@doron](https://community.dremio.com/u/doron)\
**Post date:** [December 3, 2018, 5:13pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356/3 "2018-12-03T17:13:40Z")

</div>

Hi,

How are you retrieving the ID of the dataset when you are creating the reflection? Most likely what you need to do is use the [by-path endpoint](http://docs.dremio.com/rest-api/catalog/endpoints.html#retrieve-a-catalog-entity-by-path) to get the id of the dataset you want to reference.

---

<div class="post-metadata">

**Author:** ![Monika\_Goel](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@Monika\_Goel](https://community.dremio.com/u/Monika_Goel)\
**Post date:** [December 4, 2018, 3:55pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356/4 "2018-12-04T15:55:53Z")

</div>

@doron Thanks for your reply. Yes, I have used get Catalog by-path endpoint and HDFS dataSet id returned by it is ‘dremio:/CMITCluster/dremio/“GE”’. As per my understanding id should be something like ‘a0c84110-67c2-46ce-8582-d3e079a5e9d8’.

In case of PostgreSQL source, id is returned in correct format and able to create Reflection for PostgreSQL while it fails for HDFS source.

Please suggest how to mitigate this error.

---

<div class="post-metadata">

**Author:** ![doron](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/doron/32/294_2.png) [@doron](https://community.dremio.com/u/doron)\
**Post date:** [December 4, 2018, 5:36pm UTC](https://community.dremio.com/t/error-creating-reflection-using-rest-api/2356/5 "2018-12-04T17:36:19Z")

</div>

@Monika_Goel,

For filesystem based sources such as HDFS, we do not automatically create datasets for each item in the source as they are potentially millions of them and that would be expensive - plus often we don’t know how to properly format the data without user input. That is why in the UI if you click on a file in HDFS you are asked to identify its type and other formatting options.

In this case you would have to promote the GE entity (its either a file or a folder). In fact, when you do the by-path call, the `entityType` returned won’t be `dataset` but `file` or `folder`. We have docs on how to [promote using the API](http://docs.dremio.com/rest-api/catalog/endpoints.html#promote-a-folder-or-file-to-a-dataset) or you could use the UI. Only once its promoted can you add reflections.
