Forum Discussion

ghosh's avatar
ghosh
New Contributor
7 years ago

how to insert Multiple records in REST request?

What to do to pass multiple row values in JSON request parameter to post a request in SOAP UI free version?

What groovy script I shoul write?

Please help

  • rajpenumalli's avatar
    rajpenumalli
    Occasional Contributor

    if you can provide sample REST request and the values you need to pass??

    I can provide solution for you.

     

    -Rajendra

    • ghosh's avatar
      ghosh
      New Contributor

      Below is my sample REST request:

      {

      "nav_artprc" : [
      {
      "Article" : "11111",
      "Site" : "32",
      "Partner" : "12345566"
      },

      {
      "Article" : "12111",
      "Site" : "12",
      "Partner" : "12345566"
      }
      ]
      }

       

      I am able to fetch it from my groovy script now using the below codes:

      def slurper = new groovy.json.JsonSlurper()

      import groovy.json.JsonOutput

      def s = testRunner.testCase.getPropertyValue( "article")
      def list = s.split(',')
      def i = Integer.parseInt(testRunner.testCase.getPropertyValue("counter"))
      def output = " "
      //log.info list.size()
      for (i=0; i < list.size(); i++) {
      //log.info list[i]
      def output1 = new String[3]
      output1[i] = JsonOutput.toJson([Article: list[i],Site: '32',Partner: '1234566']).concat(',')
      // log.info output1[i]
      output = output.concat(output1[i])
      log.info output
      // i++

      testRunner.testCase.setPropertyValue( "counter", i.toString())

      }
      def propRemove = output[0..-2]
      log.info propRemove
      def first = '{"nav_artprc" : [ '
      def second = ' ]}'
      def prop1 = first.concat(propRemove)
      def prop = prop1.concat(second)

      log.info prop
      testRunner.testCase.testSteps["Properties"].setPropertyValue( "Pro", prop )
      testRunner.testCase.setPropertyValue( "counter", new Integer(0).toString())

       

       

      But I am unable to fetch multiple records from EXCEL sheet.

      How I should fetch that?

      Please suggest