Service Virtualization

  • 1.  Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Aug 16, 2018 10:46 AM

    I'm trying to use the Virtual Service API to update existing VS using the following command 

     

    curl -X POST -H "Content-Type: application/zip;" -F "file1=@C:\DevTestAutomation\automation_api.mar" http://admin:admin@localhost:1505/lisa-virtualize-invoke/api/v2/vses/bak1QFW7C1oAe-dvp6FzEhX9tvvD_2f-hi7t8gVQgL/vsBuilderSessions

     

    which returns {"error":{"type":"IOException","message":"Invalid MAR file"}}

     

    Has anyone got some experience using this command? Any pointers? Any remarks? Thoughts?

     

     

    Docops for command

     

    Create a Builder Session from a MAR (Existing VS)

    Request:

    POST /vses/{vseId}/vsBuilderSessions Content-Type: application/zip  <Body: MAR file you want to upload>

    Response:

    {     "_links": {         "self": {             "href": "http://localhost:1505/lisa-virtualize-invoke/api/v2/vses/j4xHDBZf8x3-9Hmsv25utXt2HZjEoNlliAx3LVkNoBDN4VxvYo-m/vsBuilderSessions/efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU"         }     },     "id": "efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU",     "modifyDate": "2016-12-20T14:34:21-06:00",     "defaultNonLeafTolerance": "WIDE",     "name": "test001",     "description": "Optional description",     "defaultLeafTolerance": "LOOSE",     "version": "2",     "createDate": "2016-12-20T14:34:21-06:00" }

    The request should have a VS MAR file with content type set to application/zip. A successful response returns a JSON object that represents the newly created builder session object. Using the previous example, the {sessionId} is efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU.



  • 2.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Aug 16, 2018 09:29 PM

    Hey Steven,

     

    You said you're trying to use the REST API to update a virtual service. Do you mean you want to redeploy a virtual service using its MAR file?



  • 3.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Aug 17, 2018 02:48 AM

    Hi Will,

     

    No I wish to update using the curl command shared according to the documentation this is possible, my assumption is that I've defined incorrect syntax. Wish for someone to advise?



  • 4.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Aug 17, 2018 12:08 PM

    Yes, I understand you want to call the REST API through cURL command. What I'm trying to get clarification on is what you are trying to achieve. For example, are you trying to update a virtual service by redeploying its MAR file? If that's the case, you are using the wrong REST API call.

     

    But a few pointers to begin with, you should use the following syntax for calling the REST API to deploy a MAR with basic auth

     

    curl -X POST -u admin:admin "http://localhost:1505/api/Dcm/VSEs/${vseName}/actions/deployMar" -H "Content-Type: multipart/form-data" -F "file=@C:\DevTestAutomation\automation_api.mar"

     

    The assumption is that you're trying to deploy a virtual service (MAR) to a VSE, and if this is the case then there's a prerequisite of making an initial REST API call that removes the existing virtual service from the VSE prior to making the deployment REST API call.



  • 5.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Aug 17, 2018 12:15 PM

    Thank for reply I understand this call and actually use syntax when deploying VS. What I'm trying todo is different and using the Virtual Invoke API

     

    Docops information below

     

    Add Transactions to an Existing Virtual Service from RR Pairs or a Specification Document (WSDL)

     

    Create a Builder Session from a MAR (Existing VS)

    Request:

    POST /vses/{vseId}/vsBuilderSessions
    Content-Type: application/zip
    <Body: MAR file you want to upload>

    Response:

    {
        "_links": {
            "self": {
                "href": "http://localhost:1505/lisa-virtualize-invoke/api/v2/vses/j4xHDBZf8x3-9Hmsv25utXt2HZjEoNlliAx3LVkNoBDN4VxvYo-m/vsBuilderSessions/efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU"
            }
        },
        "id": "efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU",
        "modifyDate": "2016-12-20T14:34:21-06:00",
        "defaultNonLeafTolerance": "WIDE",
        "name": "test001",
        "description": "Optional description",
        "defaultLeafTolerance": "LOOSE",
        "version": "2",
        "createDate": "2016-12-20T14:34:21-06:00"
    }

    The request should have a VS MAR file with content type set to application/zip. A successful response returns a JSON object that represents the newly created builder session object. Using the previous example, the {sessionId} is efrsjq_mqVTNwXYsmQ9vxE1dYTwWNy07FD8ioKuZmVNugsgWHAU.

     



  • 6.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)
    Best Answer

    Posted Aug 17, 2018 12:57 PM

    Got it. So the error message says it's an invalid MAR file. There are two types of MAR files one for test cases and one for virtual service, I would double check that you have created the right type of MAR file, and also if you have provided the correct path to the MAR file.



  • 7.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Sep 05, 2018 11:00 AM

    Hello Steven,

     

    Is it still an issue for you?

     

    Heloisa



  • 8.  Re: Virtual Service API Create a Builder Session from a MAR (Existing VS)

    Posted Sep 06, 2018 03:14 AM

    Now resolved thanks