Forum Discussion

YeetusDeletus's avatar
YeetusDeletus
Occasional Reader
Jul 30, 2026

URLs not accessible when running python script in sandbox

I have a script:

import requests

try:
    r = requests.get("https://google.com", timeout=10)
    print("Status:", r.status_code)
    print("Headers:", dict(r.headers))
    print("Body:", r.text[:300])
except Exception as e:
    print(repr(e))

When I run it with an agent, it gives me this error:

I have no idea how to make the URL valid for the conversation and it doesn't work with any URL I have provided so far.

1 Reply

  • The 403 is expected sandbox behavior, not a malformed requests call. The screenshot shows x-ms-block-by: sandbox-proxy and says the URL is not relevant to the conversation. Microsoft documents Code Interpreter as an isolated Python environment that restricts network access and accesses only inputs provided in the session. You cannot make arbitrary requests.get calls succeed by changing the URL, headers, or timeout. For data analysis, download the source outside the sandbox, upload the permitted file to the conversation, and have the agent process it. If the agent needs live data, expose the approved service through a supported connector, agent action, or API integration and authenticate there; use Code Interpreter only for returned data. For a simple HTTP test, run the script in your local Python environment. If a URL supplied through an approved integration is still blocked, capture the 403 headers and conversation ID and raise an administrator support case.