# \`huggingface\_hub.upload\_file\` returns a 404 error

**URL:** <https://discuss.huggingface.co/t/huggingface-hub-upload-file-returns-a-404-error/16014>\
**Category:** 🤗Hub\
**Created:** [March 23, 2022, 11:41pm UTC](https://discuss.huggingface.co/t/huggingface-hub-upload-file-returns-a-404-error/16014 "2022-03-23T23:41:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SocialGrep](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/socialgrep/32/3014_2.png) [@SocialGrep](https://discuss.huggingface.co/u/SocialGrep)\
**Post date:** [March 23, 2022, 11:41pm UTC](https://discuss.huggingface.co/t/huggingface-hub-upload-file-returns-a-404-error/16014/1 "2022-03-23T23:41:06Z")

</div>

Good day,

I am trying to upload files to a HF dataset programmatically. The sequence of my actions is as follows:

```auto
huggingface_hub.create_repo(
        name=dataset_slug,
        private=True,
        repo_type="dataset"
)

huggingface_hub.upload_file(
            path_or_fileobj="{LOCAL_DIRECTORY}/README.md",
            path_in_repo="README.md",
            repo_id="{USERNAME}/" + dataset_slug
)

```

The second command fails with:

```auto
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/{USERNAME}/{DATASET_SLUG}/upload/main/README.md

```

USERNAME, LOCAL\_DIRECTORY, and DATASET\_SLUG are replaced appropriately. Am I doing something wrong, or is it a bug on HuggingFace’s end?

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [March 24, 2022, 8:44am UTC](https://discuss.huggingface.co/t/huggingface-hub-upload-file-returns-a-404-error/16014/2 "2022-03-24T08:44:37Z")

</div>

Hi there! `upload_file` also has a parameter which is `repo_type`. You should set it to “dataset” as well for this to work.
