cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
N0AH
Frequent Visitor

Predict connector BadRequest and InvalidPredictionInput error with File Content

I have created an AI Builder model for invoices. I am trying to use it in a Power Automate flow that is triggered when a new file is created in a SharePoint document library, but I am getting the error below:

{"operationStatus":"Error","error":{"type":"Error","code":"InvalidPredictionInput","message":"Inference input for model 6edeea37-...-e22f4fc4e2e7 is invalid","properties":{"BackendErrorCode":"InvalidInferenceInput","DependencyHttpStatusCode":"400"}}} 

 

flow_error.JPG

I have read multiple solutions to similar problems and they talk about using base64() encoding or to use a string() around the File Content. You can see these posts here. Unfortunately, I don't have the option to enter a JSON structure, as I only have two parameters: the mime type and the document (see image below)

 

flow_error2.JPG

I tried creating the expression by hand and the resulting expression is 

base64(triggerOutputs()?['body']) but I got exactly the same error. It is interesting that if I use the decodeBase64() function, as shown here
decodeBase64(string(triggerOutputs()?['body'])) then the Predict action works "apparently" fine as shown below.
 
flow_error3.JPG
Unfortunately, it does not return any value.
 
flow_error4.JPG
I have tried to fix this for hours but, so far, nothing works. I appreciate any help on this regard.
 
Thank you
1 ACCEPTED SOLUTION

Accepted Solutions

We tried again yesterday with a two new flows and it worked. I don't know what caused the problem. Probably the PDF files were corrupt. Thanks for the time, Joe! Very appreciated

View solution in original post

14 REPLIES 14

Hi @N0AH,

 

Thanks for posting the question.

What is the type of the file you are looking to process? PDF? JPEG? PNG?


Try replacing the Document type input parameter from the Content-type attribute to:

  • If the file is a .jpeg image: image/jpeg
  • If the file is a .png image: image/png
  • If the file is a .pdf document : application/pdf

Let us know if this helps.

Thank you. I tried, but I still get the same error. I think it has to do with the format of the file content. I have noticed that when I feed the model with one single file it works, but when I try to take the file content from either an incoming email or a new file in SharePoint, then it does not work.

 

Thank you!

Thanks for the update @N0AH,

 

If you take that file that you are uploading to SharePoint, and do a Quick test on the Model details page, do you get results back?

 

2020-05-07_23-20-54.png

 

 

I tested the model and it works fine. It recognizes all of the values correctly. see image below:

 

flow_error5.JPG

 I peeked at the code using the ellipsis / peek code option in the Predict module and I found this:

 

flow_error_predict_json.JPG

If you see the highlighted part, the Predict module has a "Document" parameter. I am feeding the "File Content" parameter in the item/requestv2/base64Encoded part of the code and it is receiving the "body" value in the outputs from the "Get file content" module (@outputs('Get_file_content')?['body']).

 

flow_error_6_new_flow.JPG

 

 

So I decided to take a look at what are the real inputs that are being fed to the predict module. I did this by running the flow, checking the inputs for the Predict module:

 

"item/requestv2/mimeType":"application/pdf","item/requestv2/base64Encoded":{"$content-type":"application/pdf","$content":"SlZCRVJpMHhMamNOTVNBd0lHOWlh

you can see that the Predict module is not receiving the base64Encoded that is expecting. Instead, it is receiving a JSON structure that contains the $content-type and the $content string, probably not encoded base64. I suspect this is the reason for the error. Somehow I think I need to feed only the $content part converted to base64. So I took this parameter and I created the following expression:  

 

base64(string(outputs('Get_file_content')?['body']?['$content']))

 

and I put it into the Predict module, where it is expecting the "Document" parameter like so:

 

flow_error_8_with_base64_expression.JPG

 

The flow still failed, but when I check the inputs of the Predict module I see that the "Document" parameter is now only the base64 encoded of the file content. I got rid of all the other parameters (as shown below). However it still fails. I suspect I am very close, it is that somehow I need to provide the file content in some different format for the Predict module to be able to process it, but I don't know how I should format it. 

 

"item/requestv2/mimeType":"application/pdf","item/requestv2/base64Encoded":"U2xaQ1JWSnBNSGh

 Any ideas?

Thanks @N0AH for the update.

The flow that you are trying to build should work without having the need to do base64 transformation. 

 

I'll send you a private message to see if we can jump into a call and have a look at this issue together. 

2020-05-09_17-30-55.png

 

We tried again yesterday with a two new flows and it worked. I don't know what caused the problem. Probably the PDF files were corrupt. Thanks for the time, Joe! Very appreciated

@JoeF-MSFT Thank you for the help and the time. Very appreciated!!

Hi @JoeF-MSFT we are facing the same issue with a predict model using pdf file but getting a Bad Request error - would you be able to provide the solution used above to solve the issue, please? 

 

Thanks! 

Hi @yabela - it seems this was caused today by an incident that is now resolved. Let us know if this is not the case.

For future visitors of this forum thread, we now recommend to use the Process and save information from forms action in the AI Builder connector, instead of the Predict action. 🙂

JoeF-MSFT_0-1618346274253.png

 

@JoeF-MSFT Thanks! 

"We tried again yesterday with a two new flows and it worked. I don't know what caused the problem. Probably the PDF files were corrupt. Thanks for the time, Joe! Very appreciated"

 

It might not be corrupted PDFs.. I ran into this exact issue and realized that I had not tested the use cases of processing an email that had multiple attachments of different types (those pictures of links to facebook, twitter, etc were coming in as attachments).  My original test emails only had a PDF that was a match for the model and no other attachments.  My following test emails (2 days later) gave me the error shown at the top of this post.  The emails that gave me errors had multiple attachments because the pictures of logos and others are all included in the Attachments array.  Those attachments of other types were what was breaking my model and flow.  I filtered the attachments to only process PDFs and "presto" it worked! Testing with a PDF that doesn't match the expected model will create different errors because it won't find the expected values, but it'll fail also and I need to build in some 'on failure' steps to account for those errors.

Thanks a lot @ericsnell for sharing this knowledge back! 🙂

mind sharing how you did this? encountering the same issue.

Hey Guys! Do you mind to clarify how you manage to do this filter to proccess only PDF's?

I'm having this same issue and the e-mail I'm trying to process is a standard e-mail from a specific plataform where someone fill a form and we get the notification on the e-mail with the form attached, but I'm guessing this e-mail has a lot of attachments besides the PDF (company logo or signature, for instance)

 

I tried some solutions I found here, even the "attachment is inline" solution, but nothing worked. Running a quick test for the model works fine, but I get badrequest error when the flow is triggered

 

Someone to help out?

 

EDIT: For those wandering here with the same issue, I manage to get it working by:

- filtering the PDF's with this tip: https://www.youtube.com/watch?v=hytNQNMb89g

- Changing the trigger: Apparently I was using an old version of the email trigger? For some reason the AI Builder could identify the content type (pdf) but no the form (content bytes). I deleted every action and trigger from my flow, started designing it again and it worked 

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,430)