0

I have a PowerShell runbook in Azure and I'm calling it from PowerAutomate. I would like to return a json object for further processing. I tried 3 versions:

$credential = Get-AutomationPSCredential -Name 'messages'
$connection = connect-microsoftteams -credential $credential
$q = Get-CsCallQueue | convertto-json
write-output $q

or

$q = Get-CsCallQueue
return $q

or this:

$q = Get-CsCallQueue | convertto-json
return $q

In all 3 cases the response body is string like:

"body": "{\r\n "DisplayDistributionLists": "532bc784-f6c4-499c-aaad-47478aa2d890",\r\n "DisplayUsers": {\r\n },\r\n "DisplayAgents": "46986d86-6128-441b-a042-8caceecaa324...

When I look at the job, I can see that it is returning the Json array. What can I do to make Flow recognise that a json object is returned, not a string?

vilmarci
  • 451
  • 10
  • 31

1 Answers1

0

I assume your flow's trigger is 'When an HTTP request is received', do you submit your header with Content-type: application/json? Next to that, your JSON schema has to be filled in, in the trigger's schema. Is this done correctly?

Iona Varga
  • 509
  • 2
  • 8
  • No. The way around. The flow triggers the runbook that returns value to the flow. – vilmarci Jan 27 '22 at 13:54
  • Parse JSON action where you process the output so PowerAutomate knows its JSON – Iona Varga Jan 27 '22 at 14:43
  • I know. The problem is not parsing a valid json, but when it arrives inside the flow, it is a string, with all sort of escape characters. – vilmarci Jan 27 '22 at 15:44
  • Have you generated your schema by an example via the wizard? The tabs and newline shouldn't matter, I guess your schema is invalid. – Iona Varga Jan 28 '22 at 14:17