Forum Discussion

rachellawrence's avatar
rachellawrence
Occasional Visitor
20 days ago

Send Request Operation - Response Body?

Is there no way to use the Send Request operation GET method and save it to a variable? I created a keyword test that will only open the URL on a server. It grabs a password from CyberArk that changes every day. Because of CyberArk's security, the URL will only open in the server. The Send Request runs but since there's no response body option, there's no where to save the json that it grabbed. I've already tried assigning a variable to the Body, but that's a request body, not response body so it doesn't work. I've tried just coding it but just gives a syntax error on the server/pipeline, but when ran just in TestComplete, it gives a certificate authority is invalid which means it should work fine. Is there a workaround for being able to set the response body as a variable on a Send Request operation so that I may parse the JSON.

EDIT: found a solution using script only, thanks!

3 Replies

  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    Hi rachellawrence,

    I hope you are doing well.  The link rraghvani​ posted is what I have used with this type of work.  If you are working with an API extensively I would recommend looking at SOAP UI or Ready API.  The methods available in TestComplete are very limited in comparison.  

    function sendGetRequest() {
      // This is a call using the aqHttp helper object.  It is limited and will not return large datasets.
      let url2 = "https://api.XXXXXXX.com/InventoryManagement/ReceivingGridSelect?PurchasingDocument=1111";
      let request = aqHttp.CreateGetRequest(url2);
      let response = request.Send();
      
      if (response.StatusCode == 200) {
        Log.CheckPoint("Response received: " + response.Text);
      } else {
        Log.Error("Request failed with status: " + response.StatusCode);
      }  
    }


    ... If you find my posts helpful drop me a like! 👍 Be sure to mark the solution to help others out and to give credit the person who helped you. 😎


  • scot1967's avatar
    scot1967
    Icon for Champion Level 3 rankChampion Level 3

    I should also mention ReadyAPI pairs with TestCompete nicely and SoapUI can as well though it is a bit more cumbersome to link and lacks the robust feature set in ReadyAPI.