In Azure Logic Apps I am trying to get Teams ID after creating it from the HTTP request. I then used Compose and Parse JSON to see the results.
The outputs will look as follows (shortened version):
"body": { "Location": "/teams('TeamsID')/operations ('operation ID')", "request-id": "request ID", "Content-Lenght": "0"
The TeamsID will be different on each run so I can't set it up as a static variable. What I am trying to achieve is to pull the TeamsID to later set it up as variable.
I am going to assume that the output indeed looks as provided - { "Location": "/teams('AAA-BBB-CCC-DDD')/operations('AAAA-BB-CCC-DDD')", "Strict-Transport-Security": "max-age=31536000", "request-id": "CCC-CCCC-CCC-CCCC", "client-request-id": "CCCC-CCCC-CCCC", "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"UK South\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"004\",\"RoleInstance\":\"LO1PEPF0000323A\"}}", "Date": "Sat, 1 Jul 2024 16:20:34 GMT", "Content-Location": "/teams('AAA-BBB-CCC-DDD')", "Content-Length": "0" }
- with single quotes etc., and not as specified e.g. in this Microsoft article: Create teams and manage members using the Microsoft Teams API. In any case, if the format of the output in your question is wrong, the approach to extract the Teams ID would still be similar to the one described below.
Step 1 - Initialize an empty string variable:
Step 2 - Create a team using an HTTP request, receive a response in the expected format:
{
"Location": "/teams('AAA-BBB-CCC-DD1')/operations('AAAA-BB-CCC-DD2')",
"Strict-Transport-Security": "max-age=31536000",
"request-id": "CCC-CCCC-CCC-CCC3",
"client-request-id": "CCCC-CCCC-CCC4",
"x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"UK South\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"004\",\"RoleInstance\":\"LO1PEPF0000323A\"}}",
"Date": "Sat, 1 Jul 2024 16:20:34 GMT",
"Content-Location": "/teams('AAA-BBB-CCC-DD5')",
"Content-Length": "0"
}
Step 3 - Extract the Teams ID value by firstly split
ting the Location
value using the forward slash as a delimiter, and secondly splitting the second item of the result array using the single quote as a delimiter; the second item of that array would hold the value you need to assign to your variable:
@{split(split(body('Create_a_team')?['Location'], '/')?[1], '''')?[1]}
Result: