How Invoke API call can return JSON response instead of XML response

book

Article ID: 141606

calendar_today

Updated On:

Products

CLOUDTEST CA Application Test CA Cloud Test Mobile MOBILECLOUD Service Virtualization

Issue/Introduction

When using Invoke API calls getting the default XML response. How Invoke API call can return JSON response instead of XML response?

For example, the call http://RegistryServerHostName:1505/api/Dcm/VSEs will return the below response in XML:

<?xml version="1.0" encoding="UTF-8"?>
<VseList xmlns="http://www.ca.com/lisa/invoke/v2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ca.com/lisa/invoke/v2.0 VseList.xsd" href="http://localhost:1505/api/Dcm/VSEs" type="application/vnd.ca.lisaInvoke.vseList+xml">
  <Vse name="VSE" href="http://localhost:1505/api/Dcm/VSEs/VSE" type="application/vnd.ca.lisaInvoke.vse+xml">
    <ConsoleURL>http://9SW51X2:1505</ConsoleURL>
    <HostAddress>9SW51X2</HostAddress>
    <VirtualServiceList href="http://localhost:1505/api/Dcm/VSEs/VSE" type="application/vnd.ca.lisaInvoke.virtualServiceList+xml">
      <VirtualService name="UserControlService_Failover" href="http://localhost:1505/api/Dcm/VSEs/VSE/UserControlService_Failover" type="application/vnd.ca.lisaInvoke.virtualService+xml">
        <ModelName>UserControlService_Failover</ModelName>
        <EndTime>1969-12-31 18:00:00</EndTime>
        <Capacity>1</Capacity>
        <UpTime>0:30:12</UpTime>
        <TransactionsPerSecond>0</TransactionsPerSecond>
        <TransactionCount>0</TransactionCount>
        <PeakTransactionsPerSecond>0</PeakTransactionsPerSecond>
        <ThinkScale>100</ThinkScale>
        <ErrorCount>0</ErrorCount>
        <AutoRestartEnabled>true</AutoRestartEnabled>
        <Status>2</Status>
        <StartTime>2019-12-10 16:30:03</StartTime>
        <ExecutionMode>Failover</ExecutionMode>
        <ConfigurationName>C:\Users\pg683490\lisatmp_10.5.0\lads\9A8A15451B9C11EA9D5058A0231C993A\UCS\Configs\project.config</ConfigurationName>
        <GroupTag />
        <ResourceName>8113 : http :  : /itko-examples/services/UserControlService</ResourceName>
        <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/UserControlService_Failover/actions" rel="down" />
        <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/UserControlService_Failover/actions/start" rel="start" />
        <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/UserControlService_Failover/actions/stop" rel="stop" />
        <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/UserControlService_Failover/actions/resetCounts" rel="resetCounts" />
      </VirtualService>
      </VirtualServiceList>
    <LifetimeTransactionCount>47</LifetimeTransactionCount>
    <RollingTransactionCount>0</RollingTransactionCount>
    <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/actions" rel="down" />
    <Link href="http://localhost:1505/api/Dcm/VSEs/VSE/actions/deployMar" rel="start" />
  </Vse>
</VseList>

 

Cause

Miss configuration of Response header.

Environment

Release : All Invoke API supported versions of DevTest

Component : CA Service Virtualization

Resolution

Configuring the API request call http://RegistryServerHostName:1505/api/Dcm/VSEs with "Accept:application/vnd.ca.lisainvoke.virtualService+json" header element resolves the issue.

Additional Information

http://RegistryServerHostName:1505/api/Dcm/VSEs will show the Response headers configuration information as below:

Attachments