Jesse
07/21/2025, 10:30 AMkey
in the query?Marvin
07/21/2025, 10:30 AMMarvin
07/21/2025, 10:30 AMmy%2Fasset%2Fkey
- The full endpoint would look like: .../assets/my%2Fasset%2Fkey
Here's a Python example of how to properly encode the key:
python
from urllib.parse import quote
asset_key = "my/asset/key"
encoded_key = quote(asset_key)
# encoded_key will be "my%2Fasset%2Fkey"
If you're using a REST client or making HTTP requests directly, make sure to properly URL-encode the key portion of the path. Most HTTP client libraries will handle this automatically if you provide the unencoded key as a path parameter rather than constructing the URL manually.
Note that this follows standard URL encoding practices where:
- Forward slashes (/
) become %2F
- Spaces become %20
- Other special characters are similarly encoded
If you're encountering any specific errors with certain characters in your asset keys, please let me know and I can provide more targeted guidance.Jesse
07/21/2025, 10:34 AM<s3://results/data/n0000.json>
?Marvin
07/21/2025, 10:37 AMMarvin
07/21/2025, 10:37 AM<s3://results/data/n0000.json>
contains several characters that need special encoding:
- The angle brackets < >
- The forward slashes /
- The colon :
Here's how to properly encode this in Python:
python
from urllib.parse import quote
asset_key = "<s3://results/data/n0000.json>"
encoded_key = quote(asset_key)
print(encoded_key)
# Output: %3Cs3%3A%2F%2Fresults%2Fdata%2Fn0000.json%3E
The encoded string breaks down as follows:
- <
becomes %3C
- s3:
becomes s3%3A
- //
becomes %2F%2F
- Additional /
becomes %2F
- >
becomes %3E
So when making the DELETE request to the Prefect Cloud API, your final URL would end with:
.../assets/%3Cs3%3A%2F%2Fresults%2Fdata%2Fn0000.json%3E
If you're using a REST client library like requests
, you can let it handle the encoding by passing the unencoded key as a parameter:
python
import requests
asset_key = "<s3://results/data/n0000.json>"
response = requests.delete(
f"<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/assets/{asset_key}>",
headers={"Authorization": f"Bearer {api_key}"}
)
Most HTTP client libraries will handle the URL encoding automatically when the key is passed as part of the path parameters rather than being manually concatenated into the URL string.
Let me know if you encounter any specific errors with this encoding or if you need help with a different HTTP client!Jesse
07/21/2025, 2:36 PM../assets/key?key=X
.Nate
07/22/2025, 3:08 AMNate
07/22/2025, 3:09 AMJesse
08/14/2025, 2:11 PMNate
08/14/2025, 2:11 PMJesse
08/14/2025, 2:12 PMNate
08/14/2025, 2:12 PMuv run <https://gist.githubusercontent.com/zzstoatzz/c8a4ad709876c44cefd40e65ac983485/raw/5dcdd854799b5f42558514b9a6870fda221aa735/asset_manager.py> list
Nate
08/14/2025, 2:13 PMJesse
08/14/2025, 2:13 PM