Active IQ Unified Manager Discussions

WFA - Enabling JSON Responses

lil_baby_james
13,844 Views

I'm looking to get a WFA instance to respond via JSON when making REST-based calls to it. Right now when I query "https://server-name/rest/workflows" or any other REST-based URLs, I get back an XML response. The WFA REST primer shows that it supports JSON, but I'm unsure how to get it to talk this way. Do I need to configure or enable something? Appreciate the help.

1 ACCEPTED SOLUTION

yaron
13,339 Views

Support for JSON was added in WFA v4.1.

View solution in original post

26 REPLIES 26

mirko
3,583 Views

$output = Invoke-RestMethod -Method Post -Uri $workflow_execution_uri -Credential $credentials -Body $jsonInput -ContentType "application/json"

 

You should "post", not "get".

And pass along a body too with the input

sinhaa
3,539 Views

@CAPATEL_NET1984

 

I have did below as i wanted to get filter output

----

 

For a filter, the method applicable is GET itself.

 

If you want JSON response for method GET you need to send this information in Request Header. Content type in GET are ignored. See my post in the previous responses to this very thread.

 

You need to add the following key-value pair in your GET Request header.

 

 'Accept'='application/json'

 

 

 

In powershell, do this

 

$output = Invoke-RestMethod -Method get -Uri $workflow_execution_uri -Credential $cred -Headers @{"Accept"="application/json"}

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

CAPATEL_NET1984
3,519 Views
$output = Invoke-RestMethod -Method get -Uri $workflow_execution_uri -Credential $cred -Headers @{"Accept"="application/json"}

 here is the error i am getting

invoke-RestMethod : The 'Accept' header must be modified using the appropriate property or method

 

 

 

 

 

sinhaa
3,499 Views

@CAPATEL_NET1984

 

This error is not related to WFA. Its being thrown by powershell. Some searching on the internet suggests you would need to upgrade your Powershell client ( which is calling the Invoke-RestMethod).

 

The latest version is 5.1. Try that

 

 

sinhaa

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

CAPATEL_NET1984
3,480 Views

yes for powershell version 5.1 it worked

Public