Highlighted
Respected Contributor.
Respected Contributor.
128 views

Parameterize a Request URL as text for API Testing

Hi everyone,

 

I'm new to API testing and We're having some issues trying to put parameters in a request URL, we've set some headers in the API call like the content-type which is url encoded, so in the request body we have something like this:

 

restaurant=0&login=XXXXX&admin=XXXXX&id_pos=xxxx&serial=xxx-xxx-xxx&idsmt=xxxxx

 

When we make the post request we get an .xml as response and we're trying to pass some of the values as inputs for the next calls that are very similar to the first request.So, what we want to do is pass the response data as inputs for the former request.

The XML is like this:

<setenv name="login" value="XXXXX" />
<setenv name="admin" value="XXXXX " />
<setenv name="id_pos" value="xxxx" />
<setenv name="serial" value="xxx-xxx-xxx " /

Now,  we can make it with visual tests and even other requests that accept xml as input, but we're struggling with this scenario where the xml responses are the inputs for the next requests.  So the question is: It can be done? or should I define some test data in the data pane and try to pass it in the request body. If that approach is better, what is the best way to do it?

Any advice would be apreciated.

 

Thanks!

Labels (4)
0 Likes
3 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

You can link the response to the next step. Please refer the below link.

https://admhelp.microfocus.com/uft/en/15.0-15.0.1/UFT_Help/Content/Tutorial/UFTTutorial_APITests_WADL.htm

 

Thanks,

Mango

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Hi, thanks for your response, we're trying to build a request body but we're unable to formulate it in the grid view so we're doing it in the "old fashioned way" which is concatenate strings, so far is going good but we have to do a lot of concatenation, so I was wondering if we can use a custom expression like this one:

operation={Step.XMLContent.StringToXMLActivity6.card[2].onevent.go.Sequence.postfield[1].value}&teller_login={Step.XMLContent.StringToXMLActivity6.card[2].onevent.go.Sequence.postfield[17].value}&id_pos={Step.XMLContent.StringToXMLActivity6.card[2].onevent.go.Sequence.postfield[15].value}&serial={Step.XMLContent.StringToXMLActivity6.card[2].onevent.go.Sequence.postfield[13].value}&POSTIMESTAMP=&payworks2_enabled=1

 

In this expression we set the request and we're trying to take the values from the response XML but we're not sure if this is going to work.

 

Thanks for your advice!

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Hi,

You can try to edit the Custom Expression in "Select link source" dialog and Add the content to the step.

Thanks,

Mango

 

 

0 Likes
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.