web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Azure Automation Creat...
Power Automate
Unanswered

Azure Automation Create Job Failing

(0) ShareShare
ReportReport
Posted on by 2

I've written a PowerShell script which downloads a file from a URL to the local PC then uploads that file to a SharePoint Online library. Running the script locally works but when I try getting it to run from a runbook triggered by Flows/Power Automate I get the error: Action HTTP failed; Input value wasn't JSON object. This flow is manually triggered and was working before I put the Create Job step in.

 

Screenshots and PowerShell script below, any help is greatly appreciated.

 

Screenshot1

Set Variable: actions('HTTP').outputs.headers.Location

 
Compose: concat('https://api.sendgrid.com/v3/messages/download/',substring(variables('redirect'),63,36))
 
Screenshot2
 
 
Compose 2: replace(replace(body('HTTP_2'),'{"presigned_url":"',''),'"}','')
 
Compose 3: replace(outputs('Compose_2'),'%2F','/')
 
Screenshot 3
 
 
 
PowerShell:
 
Function Download-File() {
    
    param (
        [Parameter(Mandatory=$true)] [string] $url,
        [Parameter(Mandatory=$false)] [SecureString] $secPW
        )

    $fileOut = "C:\temp\testDownload.csv"
    
    
    try {
        #Get download file and write to C:\temp\testDownload.csv
        Invoke-WebRequest -Uri $url -OutFile "C:\temp\testDownload.csv"
        Write-host "Download complete"
        #Set up Credentials
        $user = "me@mysharepointsite.com"
        $PW = "P@ssW0rd!!"
        $secPW = $PW | ConvertTo-SecureString -AsPlainText -Force
        $site = "https://mysharepointsite.sharepoint.com/sites/Test/"
       
        #Write credentials to PSCredential object
        $creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user,$secPw
        
        #Connect to SharePoint Online
        Connect-PnPOnline -Url $site -Credentials $creds
        #Upload File
        Write-Host "Upload Started"
        Add-PnPFile -Folder "test123" -Path $fileOut
        Write-Host "Upload Completed"
        
    }
    catch {
        write-host -f Red "Download failed: " $_.Exception.Message
    }
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
$url = ""
Download-File -url $url
 
Categories:
I have the same question (0)
  • Rohit Sharma354 Profile Picture
    Microsoft Employee on at

    Hello,

     

    The screenshots were not visible in your question. Are you able to run the same PowerShell script directly in Azure automation (Azure portal) outside of power automate ? This will help determine if the problem is with running the script through Create Job or specifically when doing it through Power Automate.

     

     

  • mwarner Profile Picture
    2 on at

    Hi,

     

    How do I add pictures so they're actually visible when initially posting?

     

    After testing it looks like the script doesn't run in Azure Automate, I cannot find where it is failing.

     

    When I looked at the output from the script it looks like it's doing what I expect it to do up until it's downloaded the file and written it to the stream.

     

    powershell runbook test.PNG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 308

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 226 Most Valuable Professional

Last 30 days Overall leaderboard