# REST API - Not able to promote a file to physical dataset

**URL:** <https://community.dremio.com/t/rest-api-not-able-to-promote-a-file-to-physical-dataset/5927>\
**Category:** Uncategorized\
**Created:** [July 16, 2020, 5:30pm UTC](https://community.dremio.com/t/rest-api-not-able-to-promote-a-file-to-physical-dataset/5927 "2020-07-16T17:30:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nehal](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nehal](https://community.dremio.com/u/nehal)\
**Post date:** [July 16, 2020, 5:30pm UTC](https://community.dremio.com/t/rest-api-not-able-to-promote-a-file-to-physical-dataset/5927/1 "2020-07-16T17:30:18Z")

</div>

I would like to create a dataset in Dremio via REST API doing the following. Convert file to a DataSet  
I follow the documention -  
Step 1. Get the id of the physical file via REST API:  
id: dremio:/cuddle\_dev\_s3-storage/“newstoreglidepathcsv\_1568879249742”

Step 2: POST /api/v3/catalog/encoded{id}  
-\> /api/v3/catalog/dremio%3A%2Fcuddle\_dev\_s3-storage%2F%22newstoreglidepathcsv\_1568879249742%22

Still its throws 404 error. Please help me with this.  
I am using encodeURIComponent in javascript to encode the ID

---

<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:** [July 16, 2020, 6:49pm UTC](https://community.dremio.com/t/rest-api-not-able-to-promote-a-file-to-physical-dataset/5927/2 "2020-07-16T18:49:20Z")

</div>

I built a local structure that resembles your s3 setup. I ran this to get the id:

`GET http://localhost:9047/api/v3/catalog/by-path/nas/cuddle_dev_s3-storage/newstoreglidepathcsv_1568879249742`

The id in the response is `"dremio:/nas/cuddle_dev_s3-storage/\"newstoreglidepathcsv_1568879249742\""`.

I ran this in the JS console:

`encodeURIComponent("dremio:/nas/cuddle_dev_s3-storage/\"newstoreglidepathcsv_1568879249742\"")`

which outputs:

`"dremio%3A%2Fnas%2Fcuddle_dev_s3-storage%2F%22newstoreglidepathcsv_1568879249742%22"`

I can then do a GET to get the file:

`GET http://localhost:9047/api/v3/catalog/dremio%3A%2Fnas%2Fcuddle_dev_s3-storage%2F%22newstoreglidepathcsv_1568879249742%22`

Which returns me the file.

I can promote it using CURL for example like this:

```auto
curl --request POST \
  --url http://localhost:9047/api/v3/catalog/dremio%3A%2Fnas%2Fcuddle_dev_s3-storage%2F%22newstoreglidepathcsv_1568879249742%22 \
  --header 'authorization: _dremio6d7sgacg5slt3ff5jh07p64sdi' \
  --header 'content-type: application/json' \
  --header 'x-ms-date: Fri, 27 Jul 2018 16:26:53 GMT' \
  --header 'x-ms-version: 2017-02-22' \
  --data '{
  "entityType": "dataset",
  "id": "dremio:/nas/cuddle_dev_s3-storage/\"newstoreglidepathcsv_1568879249742\"",
  "path": [
    "nas",
    "cuddle_dev_s3-storage",
    "\"newstoreglidepathcsv_1568879249742\""
  ],
	   "type": "PHYSICAL_DATASET",
    "format": {
        "type": "Text",
        "fieldDelimiter": "|",
        "lineDelimiter": "\n",
        "escape": "\"",
        "skipFirstLine": false,
        "extractHeader": false,
        "trimHeader": false,
        "autoGenerateColumnNames": true
    }
}'

```

---

<div class="post-metadata">

**Author:** ![nehal](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nehal](https://community.dremio.com/u/nehal)\
**Post date:** [July 17, 2020, 5:24am UTC](https://community.dremio.com/t/rest-api-not-able-to-promote-a-file-to-physical-dataset/5927/3 "2020-07-17T05:24:19Z")

</div>

@doron Thank you for the quick response.  
I had followed exact same steps as you mentioned above. Turns out it is the issue with our nginx server, it does not forward the request as it is.

Thank you Doron!
