Forum Discussion

krogold's avatar
krogold
Regular Contributor
7 years ago
Solved

API not working in ReadyAPI though it works in swagger or Postman

Hello,   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,f...
  • krogold's avatar
    krogold
    7 years ago

    well, finally I executed 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)
                            }
                        }
                    }
                }