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

Community site session details

Session Id : 3zZ6qbwjBk3YLlEq6UWBn3
Power Automate - Power Automate Desktop
Answered

How to attach excel file in Invoke web service action of PAD(API)?

Like (0) ShareShare
ReportReport
Posted on 20 Mar 2024 13:28:52 by 357

Hi Team

I want to attach an excel file in api in Invoke Web Service Action Please provide the solution.

Sanket1_0-1710941326364.png

 

I have the same question (0)
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,206 Super User 2025 Season 2 on 20 Mar 2024 at 17:48:13
    Re: How to attach excel file in Invoke web service action of PAD(API)?

    @Sanket1 
    Please follow the below powershell script to achieve the same.

    Deenuji_0-1710956844282.png

    Code:

     

    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''# Web API endpoint URL
    $apiUrl = \"https://localhost:44387/api/values/pivottable\"
    
    # Input file path
    $inputFilePath = \"C:\\Users\\deenu\\Downloads\\Excel A.xlsx\"
    
    # Output file path to save Excel
    $outputFilePath = \"C:\\Users\\deenu\\Downloads\\newoutputexcel.xlsx\"
    
    try {
     # Create a WebClient object
     $webClient = New-Object System.Net.WebClient
    
     # Create a new FormData instance
     $formData = New-Object System.Collections.Specialized.NameValueCollection
     $formData.Add(\"file\", $inputFilePath)
    
     # Upload the file using multipart/form-data
     $responseBytes = $webClient.UploadFile($apiUrl, \"POST\", $inputFilePath)
    
     # Save the response content as byte array to output Excel file
     [System.IO.File]::WriteAllBytes($outputFilePath, $responseBytes)
     Write-Output \"Excel file saved successfully.\"
    }
    catch {
     Write-Output \"An error occurred: $_\"
    }
    ''' ScriptOutput=> PowershellOutput

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀. If you'd like to appreciate me, please write a LinkedIn recommendation 🙏

     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 986 Moderator

#2
stampcoin Profile Picture

stampcoin 699 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 577 Super User 2025 Season 2