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

Notifications

Announcements

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)
  • 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

  • Rohit Sharma354 Profile Picture
    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.

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 245 Super User 2025 Season 2

#2
Expiscornovus Profile Picture

Expiscornovus 207 Most Valuable Professional

#3
trice602 Profile Picture

trice602 185 Super User 2025 Season 2

Last 30 days Overall leaderboard