# Cannot POST /spaces/\[myusername\]/test/predict

**URL:** <https://discuss.huggingface.co/t/cannot-post-spaces-myusername-test-predict/107806>\
**Category:** Beginners\
**Created:** [September 22, 2024, 2:26pm UTC](https://discuss.huggingface.co/t/cannot-post-spaces-myusername-test-predict/107806 "2024-09-22T14:26:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kimoono](https://avatars.discourse-cdn.com/v4/letter/k/bc8723/32.png) [@Kimoono](https://discuss.huggingface.co/u/Kimoono)\
**Post date:** [September 22, 2024, 2:26pm UTC](https://discuss.huggingface.co/t/cannot-post-spaces-myusername-test-predict/107806/1 "2024-09-22T14:26:45Z")

</div>

I am very new at this so my terminology might not be up to par. Please, bare with me 😉

I have setup a space with Gradio

I am also running Gradio locally:

The UI’s seem to worknicely.

I want to access Gradio via the API.

Locally this works fine:

```auto
curl -X POST http://127.0.0.1:7860/api/predict \
     -H "Content-Type: application/json" \
     -d '{"data": ["A sunset over a mountain", "", 0, true, 512, 512, 7.5, 5]}'

```

But when I try to call the API on the Hugging Space like this:

```auto
curl -X POST https://huggingface.co/spaces/[myusername]/[spacename]/api/predict \
     -H "Authorization: Bearer [my-hf-token]" \
     -H "Content-Type: application/json" \
     -d '{"data": ["A sunset over a mountain", "", 0, true, 512, 512, 7.5, 25]}'

```

The following is returned:

```auto
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /spaces/[myusername]/[spacename]/run</pre>
</body>
</html>

```

I tried all kinds of changes to the app.py file but nothing seems to work.

Any tips?

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [September 22, 2024, 8:39pm UTC](https://discuss.huggingface.co/t/cannot-post-spaces-myusername-test-predict/107806/2 "2024-09-22T20:39:58Z")

</div>

Try this.

> [@FastAPI Routing Issue in Hugging Face Spaces](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962):
>
> Hello everyone, I’ve deployed a FastAPI application on Hugging Face Spaces. Everything seems to be running smoothly, and there are no errors in the logs. However, when I try to access my endpoints via a browser or tools like Postman, I’m getting a “404 error” or a “Cannot POST” error. Here’s a brief overview of my setup: I have a FastAPI route defined as @app.get("/check\_request") and another one as @app.post("/recommend"). My Dockerfile specifies the CMD as CMD ["uvicorn", "app:app", "--hos…

---

<div class="post-metadata">

**Author:** ![sharktide](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sharktide/32/60369_2.png) [@sharktide](https://discuss.huggingface.co/u/sharktide)\
**Post date:** [May 23, 2026, 12:15am UTC](https://discuss.huggingface.co/t/cannot-post-spaces-myusername-test-predict/107806/3 "2026-05-23T00:15:09Z")

</div>

Idk if u need this anymore, but to post to it you must use the direct url

https://{username}-{spacename}.hf.space/your\_route
