web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Output from an HTTP Re...
Copilot Studio
Unanswered

Output from an HTTP Request in PVA

(0) ShareShare
ReportReport
Posted on by 29

Trying something very basic: "point to microsoft.com, get the output, display the output".

The expected outcome is a stream of HTML in this case, I suppose.

 

I can't seem to get any output from the HTTP Request, the variable is "undefined".

 

How's this supposed to work?

 

StephanPirson_0-1697953018250.png

 

Categories:
I have the same question (0)
  • HenryJammes Profile Picture
    on at

    Hi @StephanPirson,

     

    For HTTP request, I would typically expect you to call a REST-based API that returns data in a JSON format.

     

    You can then paste a sample payload of the JSON to properly set the format of the output variable (use "From sample data" in the Response data type). 

    What are you looking to retrieve on microsoft.com?

     

    See some public examples here: https://documenter.getpostman.com/view/8854915/Szf7znEe

     

    In enterprise scenarios, you’d typically add authentication, and you do so today in the header or body of your HTTP request. 

     

  • StephanPirson Profile Picture
    29 on at

    I tried with a REST POST api call that returns a json value first, but the activity failed to initialize the output variable. (the fast api web server was called, the value was returned by the web server, it failed both as a json and a json string).

    I didn't initialize the schema, however.

     

    I then tested string retrieval as a workaround, to no avail.

     

    Before trying to handle authentication, I'd like to be able to get some useable output without it.

     

    I don't really care about microsoft.com, I however expected that a GET call to a web server would put the resulting value in a string variable as output.

     

    Edit:

    I've just tried 3 things:

    have the fast api web server return:

    1. the string '{ "a" : 3}'

    2. the dictionary { "a" : 3}

    3. the jsonresponse based on the same dictionary

    @app.get('/api/ad/humanrequest2')
    @validateKey()
    async def humanRequest2g(request: Request):
     return JSONResponse({"a" : 3})
    
    @app.get('/api/ad/humanrequest3')
    @validateKey()
    async def humanRequest3g(request: Request):
     return {"a" : 3}
    
    @app.get('/api/ad/humanrequest4')
    @validateKey()
    async def humanRequest4g(request: Request):
     return '{ "a" : 3}'

     

    On the power virtual agent side, I've set it this way:

    StephanPirson_1-1697972626701.png

    None of the 3 attempts worked.

     

    Then I changed the response type from my calls to "Record" based on sample data

    StephanPirson_2-1697972767438.png

    The schema in question is defined here:

    kind: Record
    properties:
     a: Number

     

    The output of all 3 attempts is the same, no output provided.

    StephanPirson_3-1697972844451.png

     

     

  • StephanPirson Profile Picture
    29 on at

    I've also tried one of the APIs you list above:

    Specifically this one: cat-fact.herokuapp.com/facts/

     

    Copy/pasted the output of that page in the "from sample data"

    kind: Table
    properties:
     __v: Number
     _id: String
     createdAt: String
     deleted: Boolean
     source: String
     status:
     type:
     kind: Record
     properties:
     sentCount: Number
     verified: Boolean
    
     text: String
     type: String
     updatedAt: String
     used: Boolean
     user: String

     

    StephanPirson_0-1697975231310.png

    The output is an undefined table variable.

     

    Does anyone have a sample that works?

  • HenryJammes Profile Picture
    on at

    Try to paste this YAML in a new topic code view:

     

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnRecognizedIntent
     id: main
     intent:
     displayName: HTTP Request
     triggerQueries:
     - HTTP Request
     - Cat Fact
    
     actions:
     - kind: SendActivity
     id: sendActivity_zkP7Rk
     activity: You can learn more about the **HTTP Request** [here](https://learn.microsoft.com/en-us/power-virtual-agents/authoring-http-node).
    
     - kind: SendActivity
     id: sendActivity_Ith5Xv
     activity: Here I'm doing a **GET HTTP Request** to the https://catfact.ninja/fact API to get a fact about cats.
    
     - kind: HttpRequestAction
     id: xwixMk
     url: https://catfact.ninja/fact
     response: Topic.Fact
     responseSchema:
     kind: Record
     properties:
     fact: String
     length: Number
    
     - kind: SendActivity
     id: sendActivity_9eXMoM
     activity: "{Topic.Fact.fact}"

     

  • StephanPirson Profile Picture
    29 on at

    The expression on the ‘ExpressionSegment’ node at ‘undefined.topic.Untitled/main/main/sendActivity_9eXMoM’ failed with the following errors: ‘Name isn’t valid. ‘Fact’ isn’t recognized.’ (.Fact),

    ‘Invalid use of ‘.’’ (.fact). Error code: ContentValidationError. Conversation ID: d88aeeb7-94ec-4fe3-becb-8cec80879fe4. Time (UTC): 10/22/2023 2:00:08 PM.

     

    StephanPirson_0-1697983361506.png

     

    Edit:

    I tried adding the schema, and typing as comment the table instead, the error message goes away, but the content of Fact is still undefined

     

    StephanPirson_1-1697983824496.png

     

     

     

    I went back to the code view after closing the topic and opening it again, and compared it to yours, they're identical. Something's missing 😞

  • HenryJammes Profile Picture
    on at

    That's odd. I fixed the YAML in my previous post for a small typo but that shouldn't be it.
    Can you try again in a new topic and save before you try again?

    Also, what region is your bot in?

  • StephanPirson Profile Picture
    29 on at

    Same issue.

    It is indeed odd.

    StephanPirson_0-1698053197786.png

     

     

  • HenryJammes Profile Picture
    on at

    This looks like your version doesn't let you use a record variable sub-properties (fact) directly.

    Can you try with the below approach instead?

    I've added one more step.

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnRecognizedIntent
     id: main
     intent:
     displayName: HTTP Request
     triggerQueries:
     - HTTP Request
     - Cat Fact
    
     actions:
     - kind: SendActivity
     id: sendActivity_zkP7Rk
     activity: You can learn more about the **HTTP Request** [here](https://learn.microsoft.com/en-us/power-virtual-agents/authoring-http-node).
    
     - kind: SendActivity
     id: sendActivity_Ith5Xv
     activity: Here I'm doing a **GET HTTP Request** to the https://catfact.ninja/fact API to get a fact about cats.
    
     - kind: HttpRequestAction
     id: xwixMk
     url: https://catfact.ninja/fact
     response: Topic.FactRecord
     responseSchema:
     kind: Record
     properties:
     fact: String
     length: Number
    
     - kind: SetVariable
     id: setVariable_OLz8RT
     variable: Topic.Fact
     value: =Topic.FactRecord.fact
    
     - kind: SendActivity
     id: sendActivity_9eXMoM
     activity: "{Topic.Fact}"

     

  • StephanPirson Profile Picture
    29 on at

    My bot is in France, I believe.

    I'm not sure how to retrieve that information.

     

     

    StephanPirson_0-1698053571841.png

     

  • HenryJammes Profile Picture
    on at

    Can you share your topic YAML?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 273 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 271 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard