How to test API of a private space

Hi everyone,

I have created a private test space using the example code:

import gradio as gr

def greet(name):
    return "Hello " + name + "!!"

iface = gr.Interface(fn=greet, inputs="text", outputs="text")

And after checking how to test it via API using this description:

I test it via CURL:

curl -X POST -H 'Content-Type: application/json' -d '{"data": ["Juan"]}'

But I get a 404 error page saying Sorry, we can’t find the page you are looking for.

Can someone help me figure out what I’m doing wrong?

I also got the same error after making the space public :thinking:

Thanks in advance :slight_smile:

Hi @milyiyo !

Can you try passing your HuggingFace api token in the header?

Authorization: Bearer

We’ll update the Api docs page as well!

1 Like

Thanks @freddyaboulton, providing it like you suggested, works :smile: :+1:

Could you post a link to the updated API docs?

Here is how I got it to work:

$ curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer put_your_bearer_token_here' -d '{"data": ["Paul"]}'

I’m facing the same issue. I have tried the method that you’ve mentioned but still getting 404 error for my private space api for my organization.

hi @themeetjani, just tested this on a private repo API and sending the 'Authorization: Bearer HF_TOKEN' is working fine. Make sure your token is a valid READ token