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 / Sending an HTTP reques...
Copilot Studio
Unanswered

Sending an HTTP request to OPEN AI API in Copilot Studio Virtual Agents

(0) ShareShare
ReportReport
Posted on by 10

Is there an example of how to setup this http call properly? The documentation I find is not relative to the newer versions of PVA. Also, Automate "complete text..." does not work as it points to 3.5.

 

I'm sending a string to Chatgpt 4.0 that I have and expect a return answer. It passes authentication then fails. See comps.

1.jpg
3.jpg
2.jpg
I have the same question (0)
  • Freddie_B Profile Picture
    60 on at

    Does anyone can help me with this? Or has any idea why this is hapenning? I have a similiar problem

     

    Your help will be much appreciated 😊

     

    I'm attempting to send an HTTP request to OpenAI's service. It seems to function correctly overall. However, when I dynamically assign the content of the user field in the JSON payload to a variable where the question is stored, the response indicates that the information isn't found in the retrieved data. Strangely, if I manually input the same question into the content field, I receive the correct response.

    @HenryJammes , would you happen to have any clue why this is hapenning?

     

    Thanks everyone

     

    This is the code:

     

     

     

     

     

     

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnUnknownIntent
     id: main
     priority: -1
     actions:
     - kind: SetVariable
     id: setVariable_J8onVi
     variable: Topic.UserQuestion
     value: =System.Activity.Text
    
     - kind: HttpRequestAction
     id: vdrcdy
     method: Post
     url: https://ai-XXXXXXXXXXXXXXXXX.openai.azure.com/openai/deployments/gpt-35-turbo-16k/extensions/chat/completions?api-version=2023-06-01-preview
     headers:
     api-key: XXXXX-XXX-XXXXX-XXXXX-XXXX
    
     body:
     kind: JsonRequestContent
     content:
     kind: ValueExpression
     literalValue:
     dataSources:
     - parameters:
     endpoint: https://xxxx-xx-xxx-xx.search.windows.net
     fieldsMapping:
     contentFields:
     - Value: content
    
     contentFieldsSeparator: |
     
     filepathField: metadata_spo_item_name
     titleField: Name
     urlField:
     vectorFields:
    
     filter:
     indexName: sharepoint-index
     inScope: true
     key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     queryType: simple
     roleInformation: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     semanticConfiguration: default
     strictness: 3
     topNDocuments: 5
    
     type: AzureCognitiveSearch
    
     deployment: gpt-35-turbo-16k
     max_tokens: 800
     messages:
     - content: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     role: system
    
     - content: ${Topic.UserQuestion}
     role: user
    
     stop:
     stream: false
     temperature: 0
     top_p: 1
    
     response: Topic.Response
     responseSchema:
     kind: Record
     properties:
     choices:
     type:
     kind: Table
     properties:
     index: Number
     messages:
     type:
     kind: Table
     properties:
     content: String
     end_turn: Boolean
     index: Number
     role: String
    
     created: Number
     id: String
     model: String
     object: String
     usage:
     type:
     kind: Record
     properties:
     completion_tokens: Number
     prompt_tokens: Number
     total_tokens: Number
    
     - kind: SendActivity
     id: sendActivity_CUSi4i
     activity: "{Last(Last(Topic.Response.choices).messages).content}"
    
     - kind: EndDialog
     id: a1Vse4

     

     

     

     

     

     

     

     



           
  • adilei Profile Picture
    Microsoft Employee on at

    Can use assign the payload to a variable before invoking an HTTP request and validate it was populated correctly?

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 599

#2
chiaraalina Profile Picture

chiaraalina 170 Super User 2026 Season 1

#3
deepakmehta13a Profile Picture

deepakmehta13a 118

Last 30 days Overall leaderboard