For one of our REST webservices, we have implemented a GET method having the following URI:
http://ourcompany.com/doSomething/getSomething?parameter1=ABC¶meter2=123
Now, one of the headers required for security is the following
userName: ABC123, derived from concatenating the values of parameter1 and parameter2
My question is, how, in SoapUI (preferably via the SoapUI interface, itself), do I dynamically generate this header value from the parameter values supplied in the GET method?
You can create test case level custom properties instead of string value for the parameters which you have currently, say
name as PROPERTY1, and value as ABC
name as PROPERTY2, and value as 123
In the GET request step, provide values as Property Expansion, say
${#TestCase#PROPERTY1}, ${#TestCase#PROPERTY2} respectively for the parameters.
Coming to the headers, define the required header and use Property Expansion again. i.e., header name as userName and value as ${#TestCase#PROPERTY1}${#TestCase#PROPERTY2}
Hope the above should resolve the issue.
Related
I'm using SoapUI to call a web service.
I have two call, one returns an id to me, the second one use this id to make his request.
This is how the second call looks like:
https://example.com/something/{id}
With the property transfer, I have no problem retrieving the id from the first call. But when I try to add it to my endpoint (Property transfer -> Target: XXX, Property: Endpoint), the whole Endpoint is replaced by {id}.
I know I probably need to write something on the "box" belove the "Target" line, but I have no idea what.
I already tried to google it, but I seem to only found answers which are using a Groovy script and this sounds way too complicated for what I want to do. Surely, there is an easy way to do this?
Add a Properties teststep to your testcase.
Add a parameter to the Properties teststep named "id"
Change your property transfer teststep to target id inside Properties
Now open your second call, and change the value of the id parameter to ${Properties#id} and the id from your Properties teststep should be used as the value.
Your REST Request teststep should look something like this.
The "/value" at the top right, is there because I actually typed in "value" in the Properties teststep in the id parameter
If you are having problems getting your request to look something like that, try creating a new REST Request teststep, and then choose to create a new Rest request, and then type in something like
http://example.com/{id}
...when prompted for the endpoint.
Is there a way to have a parameter at the end of the URL for a Rest request?
This is the URL:
http://localhost:8000/my_user/1000
I've tried to use a parameter for the 1000, like so:
http://localhost:8000/my_user/${#Project#id_test}
This doesn't render 1000 at the end.
Is there a way to do this?
There are REST resource parameter types.
In your case, style should be Template. That should resolve the issue.
To give an example:
While adding a new REST Resource from API use below url instead of plain text value.
In the request you would see as below:
Now, in your test cases, you can use the property expression (the one you were using in the question) i.e., ${#Project#id_test} for value field/column as underline in the above image.
You may also go thru documentation if needed.
What you're trying to achieve is possible, though I'm not sure about the value you have supplied.
When you set up a RESTful Test Project is SoapUI, you define the root/base url under test.
When you set up the service call in SoapUI, you define the GET, POST settings. In the same place, you can add parameters. Click on the Request tab and you should see an empty table with headings, Name, Value, Style, Level.
You can add your parameter here.
E.g.
Name | Value | Style | Level
id | Smith | QUERY | RESOURCE
When you run the service call and you not sure your request is correct, click on the Raw tab and that will show what SoapUI is actually sending to your service.
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Tutorial:_Using_the_REST_Client_Library_to_Access_REST-based_Web_Services
Worked through this code example to run a Req/Resp via Delphi Rest client library. Curious to know if through the example shown about giving values to request parameters can be dynamic?
The value is hardcoded in the example, and a TEdit Button is linked, but I do not see how we are able to pass value from TEdit input to the Request parameter for value.
Screenshot:
Yes. You can change the request parameter values from code. Params property is just a collection of TRESTRequestParameter type items (the collection itself is of the TRESTRequestParameterList type). Write for example:
{ there seems to be only indexed access implemented for this
collection, so to access the first parameter value write }
RESTRequest1.Params[0].Value := Edit1.Text;
I have two SharePoint lists used for Support case management. The first list contains Case Numbers and information about the case. The second list contains exhibits that support the case itself.
We have a convention that the Case Number is a String supplied by the worker, ex 20150205-001. When the exhibits are joined to the Case it is through a Lookup. I want the Exhibit ID, a String, to be of the form Case Number + _[A-Z] -- and be auto-assigned.
I want to use a Workflow (MS Sharepoint Designer 2013) to assign the Exhibit ID. The problem I face is that I cannot get the actual Case Number from the Lookup. The closest I have gotten so far is to get the ID (1, 2, etc) but not the actual String value represented.
Tried working with the following URL:
http://[mySiteURL]/_api/web/lists/getbytitle([listName])/items?$select=Title,Case/Id&$expand=Case/Id&$filter=Case/Id%20eq%2020150205%45001
substituted ascii: $filter=Case/ID eq 20150205-001
without the filter I get all list items (understandably) but the filter does not work properly because the ID is not the actual lookup value.
This is a SPD 2013 limitation. You have to use a web service call from within Designer to get the specifics of a lookup column from SharePoint. You make a REST call ad then parse the JSON response for the specific data from the lookup column. It gives you access to all of the columns from the list item that you looked up:
Build {...} Dictionary (Output to Variable: requestHeader )
Call [%Workflow Context:Current Site URL%]... HTTP web service with Variable: Request (ResponseContent to Variable: PoleIDData |ResponseHeaders to Variable: dictionary |ResponseStatusCode to Variable: responseCode )
Get d/Pole_x0020_ID from Variable: PoleIDData (Output to Variable: PoleID )
Set Name to Variable: PoleID
Your actual web service call will be formatted like this:
[%Workflow Context:Current Site URL%]/_api/web/lists/GetByTitle('List Name')/Items([%Current Item:ID%])/LookupColumnNameOnOtherList
Sorry for the formatting, I would post a screenshot but I cannot.
This article is good for showing you some of the other specifics about formatting your HTTP Request, especially the Request Headers which must be setup right.
http://www.fiechter.eu/Blog/Post/37/SharePoint-2013--HTTP-Web-Service-Action---Use-Managed-Metadata-as-Text-in-Workflow
I'm creating a test case for a REST API in soapUI 4.5 where I'm going to use the content from step X to make a new call in step Y.
Ideally I'd create the REST request with some parameters, say A and B, and say that these parameters should be used in the URL:
http://myapi.com/v1/stuff/A/B
Then I'd do a property transfer step and simply set values extracted from step X into A and B.
It looks as if soapUI only lets me create querystring parameters, like this:
http://myapi.com/v1/stuff?ParamA=A&ParamB=B
This works of course, but I'd like to be able to call it both ways, to verify they're both working.
Am I missing something?
I am not a soapui expert by any means, but have just worked through a very similar scenario, so this might help you out.
Part 1: Create a paramatized resource
In my service, I have a resource called stuff:
http://{host}/stuff
I create a child resource with the below values:
Resource Name: Get stuff by ID
Resource Path/Endpoint: {stuffId}
and before clicking ok, click Extract Params - this will populate the Parameters table with an entry like:
Name | Default value | Style | Location
stuffId | stuffId | TEMPLATE | RESOURCE
then click ok. You now have a resource that allows you to dynamically supply an id:
http://{host}/stuff/{id}
you would need to repeat this to create the B parameter above (or you could create A and B as two parameters to the single resource if you never call /stuff/A without also supplying B).
Part 2: Create the test case
Now in the test case, you need to retrieve A, transfer the property, and then send a request to the above resource using the property:
In the test case, create the request to retrieve the response containing A
Right click the testcase and add a Properties step. Add a property to store the value of A.
From the response in the Outline view, right click the value of A and select "Transfer to > Property", select the property you just created and hit ok
Create a new request, using the new paramatized resource created in the first part. In the place of the id, put a reference to the property which is holding the value of A in this format:
${propertyName}
I might have done something wrong, but my test initially fails on the property transfer with "Missing source property". In the Source are of the PropertyTransfer step, I needed to set the property to ResponseAsXml
Hope this helps!