Service Virtualization

 View Only
  • 1.  DevTest API Response Only Returning XML

    Posted Feb 23, 2016 02:47 PM

    Hello,

     

    I'm trying to call the DevTest API and I am able to do so, BUT I can only ever get the response as xml - even when using the DevTest Swagger UI and selecting the json content type. Can anybody provide any insight? I am making the call as follows:

     

     

     

     

     

          $.ajax({

                    type: 'GET',              
                    dataType: "json",
                    contentType: "application/vnd.ca.lisainvoke.vse+json; charset=utf-8",
                    url: 'http://' + server + ':1505/api/Dcm/VSEs/VSE',
                    headers: {
                        'Authorization': "Basic " + btoa("username" + ':' + "password")
                    }              
                })

     

     

     

     



  • 2.  Re: DevTest API Response Only Returning XML

    Posted Feb 24, 2016 04:56 PM

    you would need to add the JSON DPH to convert the XML back to JSON on output..

    the fact that you used swagger is lost after input



  • 3.  Re: DevTest API Response Only Returning XML

    Posted Feb 29, 2016 11:35 AM

    correct me if i'm wrong, but it seems like you are talking about when creating virtual services or when recording.... I am talking about using DevTest's own API for metrics and reporting.

     

     

    Im not sure why i would need to configure something additional when from the documentation it seems to be supported natiively.



  • 4.  Re: DevTest API Response Only Returning XML

    Posted Feb 29, 2016 12:50 PM

    sorry, I didn't get that you were calling the invoke api

     

    I posted some examples using curl a while back, not using ajax..



  • 5.  Re: DevTest API Response Only Returning XML

    Community Manager
    Posted Feb 29, 2016 11:31 AM

    Did Sam's guidance help you? Did you figure things out?



  • 6.  Re: DevTest API Response Only Returning XML

    Posted Feb 29, 2016 11:36 AM

    Hi Lenn,

     

    No, I have still not been able to get the data as json, instead I am getting the devtest api response as xml and then converting to json in my ETL process.



  • 7.  Re: DevTest API Response Only Returning XML

    Posted May 24, 2016 09:11 AM

    I have just figured this out and it's spectacularly bad design on their part.

     

    The Accepts header that you're meant to pass differs depending on which part of the REST API you're invoking. For example, the two commands below both work:

     

    curl -H Accept:application/vnd.ca.lisaInvoke.vseList+json -u USERNAME:PASSWORD "http://LISAHOST/api/Dcm/VSEs"

    curl -H Accept:application/vnd.ca.lisainvoke.VirtualService+json -u USERNAME:PASSWORD "http://LISAHOST/api/Dcm/VSEs/VSE4/serviceName"

     

    Notice the bits in bold - the Accept header is different in each case. Funnily enough, that's what the root element in the response is called, vseList and VirtualService respectively (that's how I figured it out).

     

    Why on earth it's not just accepting "application/json" is beyond me.