Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - General
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

  • Gosh Profile Picture
    26 on at
    Re: How to dynamically construct the json payload correctly and send send it with HTTP Request

    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

  • Verified answer
    v-bofeng-msft Profile Picture
    on at
    Re: How to dynamically construct the json payload correctly and send send it with HTTP Request

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Copilot Studio - General

#1
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 25

#1
Pablo Roldan Profile Picture

Pablo Roldan 25

#3
stampcoin Profile Picture

stampcoin 10

Overall leaderboard