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 / Copilot Studio / How to dynamically con...
Copilot Studio
Answered

How to dynamically construct the json payload correctly and send send it with HTTP Request

(0) ShareShare
ReportReport
Posted on by 26

I want to construct a json object in my Copilot chat bot (former PVA) with the following structure:

 

 

{

 "messages": [
 {
 "role": "bot",
 "content": "message1"
 },
 {
 "role": "user",
 "content": "message2"
 }
 ]
}

 

The tricky part is that I want the strings message1 and message2 to be read from variables.

 

I tried to create a string and then parse it to json with a schema, but I had no luck with that.

 

I'll appreciate any suggestions and recommendations. 

Thanks in advance

Categories:
I have the same question (0)
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Gosh ,

     

    I've made a test for your reference:

    1\Add a 'Parse value' and set data type to 'From sample data'

    vbofengmsft_0-1712567966641.png

    2\Get schema form sample JSON

    vbofengmsft_1-1712567995942.png

    vbofengmsft_2-1712568021346.png

    Result

    vbofengmsft_4-1712568195825.png

     

    3\Get first message

    First(Topic.Var1.messages).content

    vbofengmsft_3-1712568073274.png

    4\Get last message

    Last(Topic.Var1.messages).content

     

    Best Regards,

    Bof

  • Gosh Profile Picture
    26 on at

    Hi, Thank you for the response, but the problem I want to solve is vice versa. I need to get the value from a variable and apply it on the json object. 
    best regards

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 633

#2
Vish WR Profile Picture

Vish WR 301

#3
Haque Profile Picture

Haque 219

Last 30 days Overall leaderboard