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 / Issue with new lines i...
Power Automate
Answered

Issue with new lines in text which is being passed to ChatGPT API using Invoke Web Service Action

(0) ShareShare
ReportReport
Posted on by 37

Hi All, 

I am using pad to try and summarise a long report using ChatGPT. 

One issue I am hitting involves the presence of new lines in the text that I am feeding in as the prompt.

If the prompt includes new lines I get an error (400) Bad Request; see Example A.jpg

If I remove all new lines everything works okay; see Example B.jpg

My worry is that if I remove new lines from the prompt that this will produce a prompt that is harder for ChatGPT to understand. I worry that it will not recognise different sections within the source report, etc. 

I am looking for a way to create a prompt which includes new lines that does not throw this (400) error. 

Any assistance would be greatly appreciated.

Example A.jpg
Example B.jpg
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Rory_Walsh 

     

    Just give a try with this :

     

    So may be try use Environment.NewLine instead of new line entering like below using Run .NET script action?

    Nived_Nambiar_0-1697730670177.png

     

    Nived_Nambiar_1-1697730722923.png

     

    and use that output_data variable for your prompt into your api call 

     

    Give a try and let me know whether it worked for you or not 

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • Rory_Walsh Profile Picture
    37 on at

    Hi Nived,

    Thanks for considering this. 

    When I use the approach you suggest I am still getting the bad request error.

    Looking at the output_data variable I can see that there is text on three separate lines; see attached. 

    Based on a lot of trial and error, I can only ever seem to get this to work when the content is all organised on one line within the prompt variable; see Example B in the original message. 

    (400) Bad Request.png
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Try replacing the newlines with \n. This is the character that should be accepted in the JSON body that you send to the API.

    -------------------------------------------------------------------------
    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.

  • Rory_Walsh Profile Picture
    37 on at

    Thanks Agnius; this is working 😊

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 253 Super User 2026 Season 2

#2
11manish Profile Picture

11manish 172 Super User 2026 Season 2

#3
trice602 Profile Picture

trice602 134 Super User 2026 Season 2

Last 30 days Overall leaderboard