Highlighted
Micro Focus Expert
Micro Focus Expert
527 views

(UFT/MC) Support tip: How to perform REST calls to Mobile Center REST API from UFT GUI Test?

Hi there,

Of course we can do this by calling an API Test from GUI Test as shown here; but today, I’d like to show you a new feature that was introduced on UFT 14.03 which will simplify this task.

This is the CallRestAPI method from UFT’s MobileUtil object. What is the main advantage of using this method? Well, we don’t need to care about authenticating to Mobile Center before making any other call, since this object will automatically take care of this by using the Mobile Center details we provide under Tools > Options > GUI Testing > Mobile.


Let’s say we’d like to get all users from our Mobile Center server. As you can see, we have a MC REST API operation available for this under User Management:

 MCRestAPI.png

Get this information is this easy:
print MobileUtil.CallRestAPI(REST_Get,"rest/v2/users")

Here is the output:  

output.png       

We can use other HTTP methods like:

  • REST_DELETE
  • REST_GET
  • REST_POST
  • REST_PUT


And we can add an optional third parameter for the request body/payload if needed. For example:
Print MobileUtil.CallRestAPI (Rest_Post, "rest/v2/users" , "{""name"": ""administrator@default.com"", ""password"": ""Password1"", ""roles"": [ ""admin"" ]}")

For more information, refer to our online documentation here.

Cheers!
Alvaro
Micro Focus Support

0 Likes
0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.