Does anyone have an example of migrating workflows between Alteryx servers with Powershell 5.1? Specifically, I'm looking for an example of how to format the Multipart/Form-Data request to upload a workflow to the destination server (the Post /admin/v1/workflows/ endpoint).
Solved! Go to Solution.
I did, and specify values for both but not even able to retrieve collections, a simple function indeed. Does API calls require admin login or curator good enough?
$accessToken = invoke-restmethod -uri $baseaddress/oauth2/token -method POST -body $tokenRequestBody
$headers = @{
'Authorization' = 'Bearer ' + $accessToken
}
$collections = Invoke-RestMethod -Uri $baseaddress/v3/workflows -Method GET --header $headers
Curator or Artisan? documentation says Curator is good enough - but some things will require Admin... my memory is that it's better to be an admin for most of these things?
Hi Guru, not sure where I missed out, but ran the code successfully with key/secret, no workflow uploaded. Any idea why?
No response when running $collections ?
# Define API Credentials
$apiKey = "your_key"
$apiSecret = "your_secret"
$baseaddress = "https://myalteryx/webapi"
# Request Access Token
$tokenRequestBody = @{
'client_id' = $apiKey
'client_secret' = $apiSecret
'grant_type' = 'client_credentials'
}
$tokenResponse = Invoke-RestMethod -Uri "$baseaddress/oauth2/token" -Method POST -Body $tokenRequestBody -ContentType "application/x-www-form-urlencoded"
# Extract Access Token
$accessToken = $tokenResponse.access_token
# Validate Access Token
if (-not $accessToken) {
Write-Host "Failed to obtain access token" -ForegroundColor Red
exit
}
Write-Host "Access Token: $accessToken"
# Set Headers with the Access Token
$headers = @{
'Authorization' = "Bearer $accessToken"
}
# Request Collections
$collectionsUrl = "$baseaddress/v3/collections"
try {
$collections = Invoke-RestMethod -Uri $collectionsUrl -Method Get -Headers $headers
Write-Host "Collections Data:"
$collections | ConvertTo-Json -Depth 3
} catch {
Write-Host "Error retrieving collections: $_" -ForegroundColor Red
}