Azure Ai Document Intelligence on local .PDF file with powerautomate desktop

Eric Dallaire 40 Reputation points
2025-03-20T19:30:03.5233333+00:00

Hi! Hoping someone can help me here with a little problem i have.

I'm using Azure Ai Document Intelligence with PowerAutomate and it work great on a online file (Using the Document/URL Parameter)

But if i have a file locally (EX:C:\Temp\Test.pdf) i don't know what to do.

If i do it this wayimage It says the parameter should be a binary and if a convert the file in a binary variable before like this

image I have a error during runtime saying "code": "ParameterMissing", "message": "The parameter urlSource or base64Source is required."

So to make it short what are the parameters to use for a local file?

Thanks in advance

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
2,111 questions
{count} votes

Accepted answer
  1. JAYA SHANKAR G S 3,960 Reputation points Microsoft External Staff Moderator
    2025-04-03T07:14:12.27+00:00

    Hello @Eric Dallaire ,

    It seems the connector always taking the value from Image URL field, that may be the reason you getting The parameter urlSource or base64Source is required. when setting Image URL to blank and gives it should be http or https when setting Image URL other than http urls.

    So, i found workaround that you create a python script which makes POST request and returns job URL, next run this script from PAD using command session.

    Below is the python script

    
    import requests
    import base64
    import json
    import time
    
    def execute(data):
        headers = {"Ocp-Apim-Subscription-Key": "key"}
        body = {"base64Source":data}
    
        res = requests.post("https://eastus.api.cognitive.microsoft.com/documentintelligence/documentModels/prebuilt-invoice:analyze?_overload=analyzeDocument&api-version=2024-11-30",headers=headers,data=json.dumps(body))
        if res.status_code == 202:
            return res.headers['Operation-Location']
        else:
            return res.content
    
    
    def file_to_base64(filepath):
        with open(filepath, "rb") as file:
            base64_encoded = base64.b64encode(file.read()).decode("utf-8")
        return base64_encoded
    
    
    file_path = r"Your_local_file_path\goals.pdf"  # Replace with your file path
    base64_source = file_to_base64(file_path)
    
    print(execute(base64_source))
    

    It's not that you need to use python only you can use any familiar language where you can run it using command.

    And below is the flow you need make.

    enter image description here

    1. In Open CMD session you give path to your script file folder.

    User's image

    1. In Write to CMD session give the command
      User's image
    2. Wait for few seconds.
    3. Then you Read from CMD session

    User's image

    Output :

    After the running the flow you will get output in CmdOutput.

    User's image

    You can alter the script further to retrieve results from above URL, according to your requirement you change the script.

    Let me know if you have any query.

    Thank you


2 additional answers

Sort by: Most helpful
  1. Eric Dallaire 40 Reputation points
    2025-03-21T08:42:10.6933333+00:00

    In power Automate i clicked "See more action" and added Azure Ai Document Intelligenceimage

    Added the step Analyse Document v4image

    Filled the connexion needed info

    image

    If i try with a online .pdf file it work

    User's image

    But can't make it to work with a local file like i explained in my first post

    Hope it answer your questions


  2. Jiahua Deng 0 Reputation points
    2025-07-04T12:49:35.8666667+00:00

    is it a bug of the power automate action? Any updates? @Anonymous


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.