I have a problem with requests I imported from swagger.
I have a request that looks like /m2m/fim/items?filter=(tags=DEVICE)&exclude=tags,objectClass,href,operations,attributes,metadata,factory&expand=properties&limit=20
With swagger I can test it, if I import it in Postman, it works as well. it gives me the current request:
curl -X GET \
'http://xx.xx.xxx.xxx/m2m/fim/items?filter=(tags%3DDEVICE)&exclude=tags%2CobjectClass%2Chref%2Coperat...' \
My SOAP request looks like
"GET /m2m/fim/items?filter=%28tags%3DDEVICE%29&exclude=tags%2CobjectClass%2Chref%2Coperations%2Cattributes%2Cmetadata%2Cfactory&expand=properties&limit=20 HTTP/1.1[\r][\n]"
It looks like the parenthesis of the 'filter' parameter are converted for the request (which does not happen with Postman), then my request fails.
Can anyone tell me which syntax I can use so that the parenthesis will not be interpreted ?
thank you
EDIT : In my HTTP log, I can see "Accept-Encoding: gzip,deflate" which is not what I want. In postman I have the header Accept: application/json.
I know how to remove my current header from preferences but I can't figure out how to set the wanted header. do someone knows ?
SOLUTION but not complete.
I found what was the problem, I need a header Accept: application/json
Now my problem is to add it to all the requests in all my test cases in a simple way (I have more than 400 requests)
Alex
Several ways to add a header:
in the request itself: select the header tab and add it
at resource level : in the Projects tab select the resource.
At the right of the resource path, select the Parameters tab then click on Add Parameter.
Set the name and value and select the style as HEADER.
This will set the header on all the requests below this resource in the SoapUI tab
In Projects tab, add an Event in the event handler manager. Add a RequestFilter.filterRequest event with the following:
def headers = request.requestHeaders headers.put( "Accept", "application/json" ) request.requestHeaders = headers
WARNING ! to use only once, otherwise header will be added on each request's launch
Finally I used the following groovy script:
import com.eviware.soapui.support.types.StringToStringMap
testRunner.testCase.testSuite.project.testSuites.each {
suite ->
suite.getValue().testCases.each
{
q1->
q1.getValue().testSteps.each
{
it->
if (it.getValue().config.type.equals("restrequest"))
{
//Get the headers of the current teststep
def headers = it.getValue().getHttpRequest().getRequestHeaders()
//log.info "headers = " + headers
def list = []
//Append the new header to the existing list
list.add("application/json")
log.info "list = " + list
headers["Accept"] = list;
//Set the updated header list
it.getValue().getHttpRequest().setRequestHeaders(headers)
}
}
}
}
though I think there must be a way to make the previous solution one-shot (but I'm not skilled enough in groovy to find it)