Streamlit app on Foundry: NameResolutionError when calling Foundry API despite network policy configuration

Hi everyone,

I’m running a Streamlit application inside Foundry Workshop, and the app makes a call to a Foundry API endpoint (for example, to retrieve ontology objects or trigger functions).

However, when the call executes, I get the following error:

NameResolutionError(": Failed to resolve 'foundry_host' ([Errno -2] Name or service not known)")

Here’s what I’ve already done:

  • Added the Foundry host URL to the Workspace’s network policy

  • Included the same Foundry host URL in the Streamlit app’s egress network policy

Despite that, the application still cannot resolve the host.

My questions are:

  1. Is there another recommended way to reference Ontologies or Foundry APIs from within a Streamlit app without using the explicit Foundry host URL?

  2. Is there a built-in way to authenticate or generate a token (for example using the Streamlit runtime or Foundry environment context) instead of manually calling the OAuth/token endpoint?

  3. Am I missing any configuration that enables internal API calls from Foundry-hosted Streamlit apps to Foundry itself?

Any advice, best practices, or examples from others who have integrated Foundry APIs in Streamlit would be greatly appreciated.

Thanks in advance!

This topic was automatically closed 360 days after the last reply. New replies are no longer allowed.