Service Virtualization

 View Only
  • 1.  How to identify the Http method in Rest request.

    Posted Jul 02, 2017 10:53 PM

    How to identify the Http method in Rest request.

    I'm creating a VS, wherein am using the operations GET, PUT, POST, DELETE. I need to filter the response based on http method being invoked. For e.g if it is GET, I'll route the response to Retrieve step of JDBC, create a customized response and then route to VSI response selection. Whereas if the method is PUT, POST, DELETE I shall use a different JDBC step to perform the selected operation.

     

    I'm unable to segregate the response based on Http method. Please help



  • 2.  Re: How to identify the Http method in Rest request.
    Best Answer

    Posted Jul 03, 2017 03:08 AM

    Use this in your DPH.

    method = lisa_vse_request.getMetaData().get("HTTP-Method");



  • 3.  Re: How to identify the Http method in Rest request.

    Broadcom Employee
    Posted Jul 03, 2017 03:21 AM

    Syed indicated a good way to retrieve the data you needed. As you want to do branching based on that data you can obviously also put that line in a scripted assertion added to your Listen-step (or any other step):

     

    if (lisa_vse_request.getMetaData().get("HTTP-Method").equals("GET")) return true;

    return false;



  • 4.  Re: How to identify the Http method in Rest request.

    Posted Jul 03, 2017 05:05 AM

    Thanks Syed, Danny  - It worked.

    Thank you so much