Unstructured-IO / unstructured-api

Apache License 2.0
551 stars 116 forks source link

401 response (API key) with local docker hosted server #456

Open Permafacture opened 2 months ago

Permafacture commented 2 months ago

Describe the bug Trying to use a local hosted server from the docker container and accessing with the python api. I get a 401 error API key is missing, please provide an API key in the header". This is the same as #407 except the solution there didn't fix it for me.

To Reproduce Ubuntu 20.04 docker pull downloads.unstructured.io/unstructured-io/unstructured-api:latest docker run -p 8000:8000 -d --rm --name unstructured-api downloads.unstructured.io/unstructured-io/unstructured-api:latest

then in python:

client = unstructured_client.UnstructuredClient(
    server='free-api',
    server_url=os.getenv("http://0.0.0.0:8000/general/v0/general"),
)
# insert quick start example request here
res = client.general.partition(request=req)  # this raises the error `SDKError: API error occurred: Status 401`
awalker4 commented 2 months ago

Hi there! I believe the issue is that the server param will take precedence over server_url, so the 401 here is the response from our hosted free api. Please give this a try:

client = unstructured_client.UnstructuredClient(
    server_url="http://localhost:8000",
)