Forum Discussion

Terkon's avatar
Terkon
Contributor
5 years ago

REST + environments: Need to be able to edit the endpoint when not using the default environment

Hi all,

 

when working with REST and environments I encounter the problem that I cannot edit the endpoint to my REST service when NOT using the default environment.

As soon as I switch to a custom environment, the URL textbox becomes uneditable. But I need to call different URLs during a testcase.

It is possible when I use the default environment.

See attached screenshot for details on what I mean

 

Is there any way to achieve this in my custom environments?

 

thx for any hints!

  • Hey Terkon,

    If im understanding correctly youre saying you cant edit your endpoint URLs whilst editing a teststep view?
    Thats right...right? Cos the screenshot you took was of a teststep i think.

    What version of ReadyAPI! are you using? Reason i ask this is that the reasons you shouldnt be able to do this were more obvious several versions back when you selected either Projects tab to create and edit your APIs and SoapUI tab to create and edit testcases.

    The URL you are using in a test step is setup in the API section (previously the Projects tab) and if you think of it as a parent/child relationship between the API (parent) and the teststep (child), then you wouldnt be able to alter the child because if that was allowed youd also be trying to update the parent record details.

    I dont understand why you can edit the child teststeps API details in a specific environment....that sounds like a defect to me based on how ReadyAPI worked previously (yes i appreciate the Projects/SoapUI tabs are no longer present and you edit APIs and testcases that all appear in the same frame now (like open source SoapUI), but that's just a UI overlay so its not surprising the underlying functionality hasnt changed), so i wouldnt expect you to be able to edit any API URL via a teststep.

    Using what you posted as a description:

    If this is my endpoint:
    https://myendpoint.com/

    Then for one testcase I want to call
    https://myendpoint.com/en/function1

    and for another one
    https://myendpoint.com/en/function2

    So! I'd setup my APIs considering the previously more obvious parent/child relationship when you were setting this up on the older version of ReadyAPI! (with the Projects and SoapUI tabs), and i would setup a single REST request with the following details,

    https://myendpoint.com/en/{templateParameter}

    Just to be clear, id setup a new service with the above URL which has a URI of en/{templateParameter} which would ensure youd have a uri/template parameter in the URI path at the folder immediately after the 'en' folder.
    This approach will enable you to set whatever value you want to in the test step editor.

    It's actually been about 6 months since ive setup any new services/APIs in ReadyAPI! so i haven't done it in the most recent versions without the Projects/SoapUI tabs so i'm not 100% positive on this, but i'm 99% positive this will work. At least its worked for me several times before.

    I'll give it a shot tonight when i get home on the latest version of ReadyAPI! and then reconfirm, but thats really just belts and braces. Im positive it still works like how ive described.

    Ta

    Rich
  • Hi Richie,

     

    thanks again for your input.

    While trying to implement your approach I found the option to add "resources" to an REST API, which can exactly be the "/en/function1"  or "/function2" from my example.

     

    With these entered, one for each function, I am able to assign these to an example request in the API definition and transform it into a real teststep.

    Or I can use the "link API" button in the top right corner in the teststep editor for an already existing teststep and link it so the API with the needed resource.

    It is not the most practical or handy thing, but it works and kind of make sense to me.

    Rg

    Terkon

  • groovyguy's avatar
    groovyguy
    Community Hero

    As far as I am aware, one of the the points of an environment is to NOT have to edit the URL's that you are trying to reach. I know that doesn't help you off the bat, but I am not sure of any good way to do this short of setting a Project level Property of ${Project$IP} or ${Project#URI} and then using that in the environment's endpoint field to allow you to edit them on the fly. Keeping in mind that those values will be stored PER environment, so it can get hairy to manage.

    • Terkon's avatar
      Terkon
      Contributor

      Thanks a lot for your reply!

      I am afraid that your workaround will not be applicable for me. Then it is easier to maintain two projects with different connections. Sorry.

       

      I do not understand why it should not be possible to maintain different URLs  for each teststep, or at least add an URL extension. It is possible in default.

       

      If this is my endpoint:

      https://myendpoint.com/

       

      Then for one teststep I want to call

      https://myendpoint.com/en/function1

      and for another one

      https://myendpoint.com/en/function2

       

      The extensions are even the same for each step in all environments.

      The environment switch I basically just need to switch the DB connection automatically in the JDBC teststeps between the REST teststeps.

       

      Is there a way to add these extensions to the endpoint when using a custom environment?

       

       

       

       

      • richie's avatar
        richie
        Community Hero
        Hey Terkon,

        If im understanding correctly youre saying you cant edit your endpoint URLs whilst editing a teststep view?
        Thats right...right? Cos the screenshot you took was of a teststep i think.

        What version of ReadyAPI! are you using? Reason i ask this is that the reasons you shouldnt be able to do this were more obvious several versions back when you selected either Projects tab to create and edit your APIs and SoapUI tab to create and edit testcases.

        The URL you are using in a test step is setup in the API section (previously the Projects tab) and if you think of it as a parent/child relationship between the API (parent) and the teststep (child), then you wouldnt be able to alter the child because if that was allowed youd also be trying to update the parent record details.

        I dont understand why you can edit the child teststeps API details in a specific environment....that sounds like a defect to me based on how ReadyAPI worked previously (yes i appreciate the Projects/SoapUI tabs are no longer present and you edit APIs and testcases that all appear in the same frame now (like open source SoapUI), but that's just a UI overlay so its not surprising the underlying functionality hasnt changed), so i wouldnt expect you to be able to edit any API URL via a teststep.

        Using what you posted as a description:

        If this is my endpoint:
        https://myendpoint.com/

        Then for one testcase I want to call
        https://myendpoint.com/en/function1

        and for another one
        https://myendpoint.com/en/function2

        So! I'd setup my APIs considering the previously more obvious parent/child relationship when you were setting this up on the older version of ReadyAPI! (with the Projects and SoapUI tabs), and i would setup a single REST request with the following details,

        https://myendpoint.com/en/{templateParameter}

        Just to be clear, id setup a new service with the above URL which has a URI of en/{templateParameter} which would ensure youd have a uri/template parameter in the URI path at the folder immediately after the 'en' folder.
        This approach will enable you to set whatever value you want to in the test step editor.

        It's actually been about 6 months since ive setup any new services/APIs in ReadyAPI! so i haven't done it in the most recent versions without the Projects/SoapUI tabs so i'm not 100% positive on this, but i'm 99% positive this will work. At least its worked for me several times before.

        I'll give it a shot tonight when i get home on the latest version of ReadyAPI! and then reconfirm, but thats really just belts and braces. Im positive it still works like how ive described.

        Ta

        Rich