I am attempting to send the contents of a variable, timecode_val, in the body to an HTTP service using AI Copilot Studio. The HTTP service takes JSON as input. I have created a topic with a trigger containing phrases setting an Entity, Timecode, as the first step. In the second step, I'm setting the contents of a variable, timecode_val to the entity, Timecode. In the third step, I attempt to call an HTTP Request with the following body, but I keep receiving an unknown error in the body of the script.
{ "timecode": @{variables('timecode_val')} }
Unfortunately, the online help doesn't cover the case of sending JSON variables. Perform HTTP requests - Microsoft Copilot Studio | Microsoft Learn
Might anyone know how to send a variable to an http post service using JSON format in AI Copilot Studio?
Screenshot of http request properties panel below.
I got the correct solution for this -
To add a variable to the content of JSON select JSON as the Body format and switch to the Formula Tab. You can then enter JSON strings as literals and access the variable using Topic.Var1. When entering the JSON note that the tags don't need double or single quotes. Just the values. Power FX will convert that to valid JSON with the variable value.
pass for variable as - Topic.<<Variablename>>
example - Topic.Var1
Thanks
Hello, @HenryJammes
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 SharmaVariable (Var1), that i want to pass inside HTTP post payload
HTTP - Post request payload
Output
and I try to use the following FX
Dear @HenryJammes , I got the same question with @sgupt187
I need use My own LLM to answer user's question. And I don't like get response via Power automate HTTP Action, cause 2min timeout limit.
So I plan to use HTTP POST in topic to get my own LLM(fine-tuned) response and answer user's question.
My question is How to send Var like Activity.Text in JSON content along with my prompt
{
"messages": [
{
"role": "system",
"content": "My sys prompt." #my sys prompt string
},
{
"role": "user",
"content": "Var in Copilot studio" # here, I need Var like Activity.Text. how to do that?
},
{
"role": "assistant",
"content": ""
}
],
"max_tokens": 1500,
"temperature": 0.2,
"frequency_penalty": 0,
"presence_penalty": 0,
"top_p": 0.95,
"stop": null
}
I want to send Activity.Text in JSON content along with my prompt, but it is not working.
{
"prompt": "Generate a response based on the user query present in Activity.Text."
}
Can anyone tell me a way so that I can achieve it?
Is there any way where the user query can be passed into a variable in the body of the HTTP Request feature of Microsoft Copilot Studio along with some other JSON content ?
Thanks, Henry. That fixed that issue. You rock.
Hi @billbaer
Can you switch your HTTP Request body from JSON for formula? (your endpoint will still receive JSON).
That way you can send this:
{ timecode: Topic.timecode_val }
Romain The Low-Code...
25
Pablo Roldan
25
stampcoin
10