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 / Failing to use Environ...
Power Automate
Unanswered

Failing to use Environment Variable in an Excel action

(0) ShareShare
ReportReport
Posted on by 2

Hello there !

I'm quite new using Solutions and Environment variables and I am a bit stuck in a simple process :

 

What is my problem :

When trying to get the rows of an excel file, using Environment Variables, I get an error and cannot select the right excel file nor the concerned table. I get this error :

GalleF_1-1655391541369.png

which reads "The dynamic invocation request failed with error : { "error": {"code" : "invalidRequest","message":"The provided drive id appears to be malformed, or does not represent a valid drive", "innerError":{/*followed by a bunch of different ID and tokens.*/}}}

 

And I am trying to find what can work, but i am quite stuck on it.

 

What I created :

I created a solution called NextFactory_Solution.

In it, I set 3 Environment variables :

  1. FormID : a string, which will contain the ID of a MS Forms. Default value = the ID of a form I already set for dev purposes
  2. SiteURL : a database, type Site, with default value a SharePoint site from my environment, let's call it TeamSite
  3. LibraryID : a database, with the type List, dependant on the SiteURL variable. Default value : the standard Document Library on the SharePoint site.
    Here is the settings of LibraryID :
    GalleF_0-1655391375980.png

     

  4. FilePath : a string environment variable, containing the path+filename of the excel file. In this case it is set to default value "/Client/00.Factory/MyExcelFile.xlsx"

I then added an existing flow to the solution, by clicking "Add existing > automation > cloud flow > Not in dataverse".

To sum up, this flow is triggered when a new response is submitted to a form and it goes fetch the rows of a table set in a excel file stored under the Document library of my SharePoint TeamSite.

 

When the flow was added to the solution, it was easy to put the FormID environment variable in the trigger, I got no error message.

I then added the SiteURL environment variable to the Excel action, and it worked well, because Power Automate found the right document libraries by itself into the Document Library field.
The issue is when i add the variable LibraryID, Power Automate do not show me all the folder to browse under the File field.

The error I talked to you about is appearing.

 

Now, I created the FilePath variable, but the error remains, it is just triggered by the Table field :

GalleF_2-1655392068525.pngThis error is slightly different but from the same rootcause I think. It says :
Could not retrieve values. The dynamic invocation request failed with error: {
"status": 400,
"message": "Invalid request\r\nclientRequestId: 504da1d4-b657-4ce3-94b4-5451f5b3bffe\r\nserviceRequestId: 0cb5dc87-f3fd-4a39-9399-caf5d07fdb40",
"error": {
"message": "Invalid request"
},
"source": "excelonline-ncus.azconn-ncus.p.azurewebsites.net"
}.

 

 

Could you please help me to understand what i did wrong when initializing my Environment Variables ?

 

Thanks a lot !

Have a wonderful day

Categories:
I have the same question (0)
  • MGprogrammer Profile Picture
    16 on at

    Hi,

    I have the same problem. I already have the ID of the excel file, but using environment variables for the Site and Document library seems not to work.

    MGprogrammer_0-1668441779899.png

     

  • eric_van_waas Profile Picture
    3 on at

    I have the same issue.
    If I do it without environment variable than it works fine

    If I do it with environment variable it does not work.
    If I check the raw input, and I see the drive (library) has a different GUID

     

    Without environment variable

    {
        "host": {
        "connectionReferenceName": "shared_excelonlinebusiness",
        "operationId": "GetItems"
        },
        "parameters": {
             "source": "https://XXXXXX.sharepoint.com/sites/RPA",
             "drive": "b!wK0B_z9fbkWxy04kzcFARcJCFeJiamNEnYxKu0pIr6jGra9duAwFSo0i_lP6sMJr",
             "file": "/SMSx_11_11_2022_10_40_19a.xlsx",
             "table": "Table1"
    }
      
    With environment variable
    {
       "host": {
           "connectionReferenceName": "shared_excelonlinebusiness",
           "operationId": "GetItems"
       },
       "parameters": {
             "source": "https://xxxxxxxx.sharepoint.com/sites/RPA",
             "drive": "5dafadc6-0cb8-4a05-8d22-fe53fab0c26b",
            "file": "/SMSx_11_11_2022_10_40_19a.xlsx",
           "table": "Table1"
      }
    }

  • Jose Orlando Conde Arias Profile Picture
    14 on at

    Hola,

     

    Para obtener el valor de la variable de entorno para el archivo, debes seleccionar todos los valores requeridos:

     

    1.JPG

    Luego le das en inspeccionar la acción:

    3.JPG

     

    Y el valor que está de color amarillo sería la variable de entorno de tipo cadena para el archivo de excel.   Para obtener el valor de la tabla lo hacemos con la acción de enumerar registros:

    5.JPG

    Inspeccionamos la acción:

    2.JPG

    Y el valor de color en amarillo sería la variable de entorno de tipo cadena para la tabla del archivo de excel.

    6.JPG

    Ya con todos los valores necesarios en las variables de entorno, lo reemplazamos y funciona el flujo sin problemas.

  • booster211 Profile Picture
    on at

    After strugglin, pulling my hair... i found the post and discussion here.

    I have exactly the same isse - it never works with environment variable neither compose or so

     

    A BUG?

  • Jose Orlando Conde Arias Profile Picture
    14 on at

    Follow the step by step above, that's how I solved it.

  • booster211 Profile Picture
    on at

    @JoseConde88 thank you 👍

     

    I am sure, the Excel Business Connector has some 'bugs' it can not handle environment variables.

    We have to use the solution that you are recommending, or is used a Power Automate Action Series that reads the Drive ID

     

    Solution and Discussion to this topic: Solved: Re: Get drive for Doc Library selection - Power Platform Community (microsoft.com)

     

    Have a nice day 😎

  • TomaszPoszytek Profile Picture
    170 Most Valuable Professional on at

    Hi, you are all nearly there, to solve the issue. First of all, this action requires not the library reference, but the drive id which can be obtained either dynamically from graph API: Get Drive - Microsoft Graph v1.0 | Microsoft Learn or actually read from the action's "Peek code".

    So first, select the library you want to get Excel data from, 

    TomaszPoszytek_4-1684676036855.png

    and after that, switch to "Peek view":

    TomaszPoszytek_5-1684676055440.png

     

    copy the "drive" value:

    TomaszPoszytek_6-1684676072688.png

     

    and use as a value of a "Text" env. variable, not "Data source":

    TomaszPoszytek_7-1684676100603.png

     

    Then use this variable as a custom value in action, to get data from the library:

    TomaszPoszytek_8-1684676123365.png

     

    That's it!

     

    Good luck 🙂

     

  • renanfm Profile Picture
    21 on at

    Genial. Pero tengo una pregunta, ¿cómo puedo obtener estos valores utilizando contenido dinámico?

  • Jose Orlando Conde Arias Profile Picture
    14 on at

    Hola, lo que explicaba en los hilos anteriores es para poder utilizar esas acciones con variables de entorno.  Me podrías dar más detalle de lo que quieres preguntarme.

  • renanfm Profile Picture
    21 on at

    En primer lugar, me gustaría agradecer tu respuesta, incluso después de tanto tiempo desde tu última interacción en este post.

    Bien, mi objetivo es crear tablas en Power Automate, de forma dinámica e inteligente. O sea, NO quiero utilizar configuraciones manuales, como seleccionar el sitio, definir la carpeta, elegir el archivo y seleccionar el rango de mis datos.

     

    Bueno, ya tengo casi todo listo, las variables de mis sitios, y como identificar mis archivos.

     

    Pero me encontré con un error al buscar, mediante variables, la ubicación de la biblioteca de documentos (Drive ID) y creo que tendré el mismo problema con el File (File ID).

     

     

    Cópia de Código JSON.jpg

     

    Fue entonces cuando, buscando en internet, terminé aquí. Me ha parecido muy interesante esta solución porque no la conocía.

     

    Hice una prueba usando el método "manual", seleccionando los criterios, "mostrando el código" y efectivamente los IDs están ahí.

    Cópia de Código JSON (1).jpg

     

    Ahora, ¿cómo lo hago, sin tener que "echar un vistazo al código" antes de mi flujo? Por favor, explícame cómo obtengo el Drive ID del código JSON a través de un Outputs.

     

    Gracias!

     

     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 442

#2
Vish WR Profile Picture

Vish WR 328

#3
David_MA Profile Picture

David_MA 268 Super User 2026 Season 1

Last 30 days Overall leaderboard