Hey All! I am working on a migration project and looking for a way as a non-Admin/Curator to mass download packages given a list of Workflow IDs. I've been looking at the /v1/ endpoints and it looks like as an Artisan I can use /v1/workflows/{appId}/package. Does anyone have an example script or workflow that uses that endpoint? I'm struggling to get the right GET request to download the .yzxps. 🤔
This is what chatGPT is suggesting but it returns a 401. This is what chatGPT is suggesting but it returns a 401.
import requests
import os
# Define the Alteryx Server URL and workflow ID
server_url = "https://myalteryxserver.com"
# update code to feed in a list, but testing with one workflow ID for now
workflow_id = "12345"
# Specify the path to save the downloaded workflow package on the C drive
save_path = "C:/workflow.yxzp"
# Alteryx Server authorization token
auth_token = mytoken
# Construct the API endpoint URL
api_url = f"{server_url}/api/v1/workflows/{workflow_id}/package"
# Send a GET request to download the workflow package
headers = {'Accept': 'application/octet-stream',"Authorization": f"{auth_token}"}
response = requests.get(api_url, headers=headers, stream=True, verify=False)
# Check if the request was successful
if response.status_code == 200:
# Create the directories in the save path if they don't exist
os.makedirs(os.path.dirname(save_path), exist_ok=True)
# Open a file in binary mode and save the downloaded package
with open(save_path, "wb") as file:
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)
print("Workflow package downloaded successfully!")
else:
print("Failed to download the workflow package.")