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 / Error with Invoke web ...
Power Automate
Answered

Error with Invoke web service for chat gpt

(0) ShareShare
ReportReport
Posted on by 431

{

I am creating a prompt that has multiple questions that I am concatenating with a 4 page PDF document (I OCR'd it). This is a legal document that has the usual types of punctuation. I have no control over the formatting of the PDF. I have disabled "encode request body" in the Invoke Web Service Action. When I run the flow I get the error shown. If I remove the Cleaned Document from the prompt, the flow runs without error, So the problem is with the pdf. I am thinking that I need to escape various characters but am not sure  how to proceed. (Are there examples of replace for various types of punctuation.)

 

Steve48_1-1694715806587.png

 

 

 

 

 

 

 

 

"error": {
"message": "We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}

  • Steve48 Profile Picture
    431 on at

    I am the OP. I copied the PDF into a text file and deleted all the line breaks so it is now one long text string. Still getting error

  • Steve48 Profile Picture
    431 on at

    I am the OP. I made some progress by splitting the Extracted Text on a new line which produces a list. Then I joined the list items with a space. Still getting json error. here is a new flow

    Steve48_0-1694726356387.png

     

     

     

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Can you share a screenshot of the Invoke web service action properties (clean it for any sensitive info first)? Mainly the body part of it. I don't see any JSON formatting in your flow prior to that and want to make sure you applied appropriate formatting in the body.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Verified answer
    Steve48 Profile Picture
    431 on at

    Hi Agnius. I was able to solve my problem.

    My problem was that my pdf extraction contained carriage returns.

    I solved this by using the actions Split Text (on new line) which produces a list

    And then join text (space) to regenerate the document without carriage returns. 

    I then had to crop my text for test purposes to get under the davinci token limit.

    This then worked. 

     

    Below is my final flow. For test purposes I cropped my input to get under the davinci token limit.

    Steve48_0-1694778823464.png

     

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 227 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 132

Last 30 days Overall leaderboard