Skip to main content

Notifications

Topic Creation & Management
Answered

How to send a Record type variable as JSON body for POST request in Copilot Studio

Posted on by 6

Screenshot 2024-02-29 195659.png

Every time i save my changes, the page refreshes and my changes disappear. I guess it doesnt like Topic.Transcript by itself. If i put it within brackets however and with a key (Topic.Transcript as value) then no problems. So it seems to be a type conversion issue between trying to set record variable as json object. How can i convert this variable to json? the schema of the variable is as follow: 

kind: Record
properties:
  activities:
    type:
      kind: Table
      properties:
        attachments:
          type:
            kind: Table
            properties:
              content:
                type:
                  kind: Record
                  properties:
                    $schema: String
                    body:
                      type:
                        kind: Table
                        properties:
                          text: String
                          type: String
                          wrap: Boolean

                    type: String
                    version: String

              contentType: String

        channelId: String
        conversation:
          type:
            kind: Record
            properties:
              id: String

        entities:
          type:
            kind: Table

        from:
          type:
            kind: Record
            properties:
              id: String
              name: String
              role: String

        id: String
        inputHint: String
        listenFor:
          type:
            kind: Table

        membersAdded:
          type:
            kind: Table

        membersRemoved:
          type:
            kind: Table

        name: String
        reactionsAdded:
          type:
            kind: Table

        reactionsRemoved:
          type:
            kind: Table

        replyToId: String
        serviceUrl: String
        speak: String
        suggestedActions:
          type:
            kind: Record
            properties:
              actions:
                type:
                  kind: Table
                  properties:
                    text: String
                    title: String
                    type: String
                    value: String

              to:
                type:
                  kind: Table

        text: String
        textFormat: String
        textHighlights:
          type:
            kind: Table

        timestamp: String
        type: String
  • kush-sg Profile Picture
    kush-sg 17 on at
    Re: How to send a Record type variable as JSON body for POST request in Copilot Studio

    Hello, @adilei 

    I am experiencing an issue with passing user input (variable) in the body of an HTTP POST request in CoPilot Studio. Attached are screenshots illustrating the problem.

    Could you please help me resolve this issue?

    Thank you.

    Best regards,
    Kushagra Sharma

    Variable (Var1), that i want to pass inside payloadVariable (Var1), that i want to pass inside payload

     

    HTTP - Post request bodyHTTP - Post request body

     

    responseresponse

     

  • Verified answer
    adilei Profile Picture
    adilei on at
    Re: How to send a Record type variable as JSON body for POST request in Copilot Studio

    I think it's "just" a UI issue. If you peek at the YAML code for the topic, you can see the request body is populated with whatever formula you assigned in the UI, and based on my tests, the call executes successfully.

     

    I think you can raise a case with support regarding the UI - Get Help + Support in Power Platform - Power Platform | Microsoft Learn

     

    Here is the code for my topic:

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnRecognizedIntent
     id: main
     intent:
     triggerQueries:
     - http
    
     actions:
     - kind: SetVariable
     id: setVariable_pgxUkP
     variable: Topic.body
     value: "={key:\"value\"}"
    
     - kind: HttpRequestAction
     id: syBaJ9
     url: https://myurl.com
     body:
     kind: JsonRequestContent
     content: =Topic.body

     

     

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 137,998

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,059

Leaderboard

Featured topics