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 / I cannot get the AI mo...
Power Automate
Unanswered

I cannot get the AI model to accept my base64 encoded image from a HTTP request - while opening the file manually works - Help

(0) ShareShare
ReportReport
Posted on by 19

Hello Fellow Automaters,

 

I'm running into an issue with calling the AI model (running a standard cats vs dogs detection using the Kaggle set).

When I open the file with the content to be detected with a manual trigger, it works fine

 

A very simple flow to open a file, and we see the contents of the file converted to base64, and passed on the AI Model. It runs without errors (except from detecting, need to add more samples ...)

 

Schermafbeelding 2021-09-17 om 11.40.35.png

 

Run the flow manually

 

Schermafbeelding 2021-09-17 om 11.41.19.png

 

The file is imported and the content is converted to base64, the content is passed on to the AI model

 

Schermafbeelding 2021-09-17 om 11.41.41.png

 

And succes!

Schermafbeelding 2021-09-17 om 11.41.55.png

 

However, when I tried to post this same image as base64 content through a HTTP requests, the model refuses to accept the input and fails. Imho it is exactly the same content ( opened the image and used base64encode.org to encode it).

 

This is the HTTP flow request

Schermafbeelding 2021-09-17 om 11.49.14.png

 

The HTTP POST request I send from Postman

 

Schermafbeelding 2021-09-17 om 11.49.42.png

 

The HTTP requests gets processed normally and base64 encoded image is stored in the Image attribute

 

Schermafbeelding 2021-09-17 om 11.50.27.pngSchermafbeelding 2021-09-17 om 11.50.36.png

 

However when passing the Image to the AI model, it fails with a bad request, even though the content of the image attribute is exactly the same as when I'm running it with a manual trigger. 

Schermafbeelding 2021-09-17 om 11.50.47.pngSchermafbeelding 2021-09-17 om 11.50.57.png

 

What am I doing wrong? HELP!

 

Categories:
I have the same question (0)
  • Verified answer
    Antrod Profile Picture
    Moderator on at

    Hi @ConsiglioriWim ,

     

    Did you try to convert the explicitly convert the base64 string to binary using base64ToBinary?

     

    Thanks

  • ConsiglioriWim Profile Picture
    19 on at

    No, why would I do that? The AI model expects base64, not binary. I tried by sending a url to the JPEG image, downloading it with a HTTP GET requests and saving it locally on my OneDrive and passing that to the Model. Didn't work either. Or is there an image object that can open that JPEG file and pass that object to the model, like the open file manual method?

     

  • Antrod Profile Picture
    Moderator on at

    AI Builder actions require an explicit conversion to work properly.

     

    I made the test with Form processing models and it worked (I think it's the same with object detection):

     

    1- Converted my file using the base64 encoder you provided

    2- Passed it as a string to my model fails as in your example: 

    Antrod_0-1631878284247.png

    Antrod_1-1631878295421.png

    Antrod_2-1631878375066.png

     

    3- If I convert the base64 to binary it now works properly:

    Antrod_5-1631878810231.png

    Antrod_6-1631878834318.png

     

     

     

     

    Hope that helps solve your issue.

     

  • ConsiglioriWim Profile Picture
    19 on at

    Hi @Antrod 

    Can you just expand the F(x) for calling the Base64 on the Variable, for getting the correct syntax? Thx

    I need to apply that on the image attribute. I get an error for F(x) Base64ToString('image')

    Schermafbeelding 2021-09-17 om 13.47.16.png

  • Antrod Profile Picture
    Moderator on at

    Sure, I just converted the string variable representing the file: base64ToBinary(variables('MyFileBase64String'))

     

    Let us know if that works for you!

  • Antrod Profile Picture
    Moderator on at

    Note that if the string representation of your file is within double quote you may get this error: 

    Antrod_0-1631879667738.png

    If possible try to avoid double quoting your string.

  • Verified answer
    ConsiglioriWim Profile Picture
    19 on at

    @Antrod 

    Calling base64ToBinary instead of base64ToString did the trick ! Thanks a lot!!!!!!

     

    Schermafbeelding 2021-09-17 om 13.55.31.png

     

  • Antrod Profile Picture
    Moderator on at

    Awesome 🙂

    Wish you a great automation journey with AI Builder!

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard