How to deserialize json payload passed to other feature file which accept multiple argumentsKarate: JsonPath wildcards didn't work or partly didn't workHow to enter url as global parametersIn Karate DSL, How do I resolve an Unsupported Media Type for a valid POST REQUESTLogging Messages from Java Class back to the Karate ReportExtract json data with double quotes in Karate BDDhow to dynamically set an value in json read from file in KarateHow to parse data from jason and populate in REST UrlKarate : Passing variable from one feature file to another as a query parameterKarateDSL Parsing a value from a response and adding to next scenario payload not workingHow to pass the background response value of the to another feature json in function value using KarateI am trying to read a json payload from a file and setting the values from CSV file using scenario outline and examples

How is underwater propagation of sound possible?

Intuitive methods for representation of Cartesian Coordinates in terms of Spherical Coordinates as basis

Do the villains know Batman has no superpowers?

Minimize taxes now that I earn more

Get the encrypted payload from an unencrypted wrapper PDF document

Why can't we use uninitialized local variable to access static content of its type?

What is the origin of the "being immortal sucks" trope?

Does battery condition have anything to do with macbook pro performance?

Is there any actual security benefit to restricting foreign IPs?

Does Mage Hand give away the caster's position?

As an employer, can I compel my employees to vote?

Are lay articles good enough to be the main source of information for PhD research?

What's the purpose of autocorrelation?

What's the word for a student who doesn't register but goes to a class anyway?

Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?

Who are the people reviewing far more papers than they're submitting for review?

Why do things cool down?

Lemons losing all leaves

How often is duct tape used during crewed space missions?

Is the name of an interval between two notes unique and absolute?

How do rulers get rich from war?

Unable to see packet drops on tunnels

Nested array references

What is the rail connection between Paris Charles de Gaulle Airport and Gare de Lyon like?



How to deserialize json payload passed to other feature file which accept multiple arguments


Karate: JsonPath wildcards didn't work or partly didn't workHow to enter url as global parametersIn Karate DSL, How do I resolve an Unsupported Media Type for a valid POST REQUESTLogging Messages from Java Class back to the Karate ReportExtract json data with double quotes in Karate BDDhow to dynamically set an value in json read from file in KarateHow to parse data from jason and populate in REST UrlKarate : Passing variable from one feature file to another as a query parameterKarateDSL Parsing a value from a response and adding to next scenario payload not workingHow to pass the background response value of the to another feature json in function value using KarateI am trying to read a json payload from a file and setting the values from CSV file using scenario outline and examples






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am sending multiple arguments to .feature file one of the argument is request json payload generated by using karate table. How to iterate through request payload so that post request will get one payload at a time.



Scenario: post booking

* table payload
| firstname | lastname | totalprice | depositpaid |
| 'foo' | 'IN' | 10 | true |
| 'bar' | 'out' | 20 | true |

#date will calculate using js function in background and baseURL is configured in karate.config.js file

* set payload[*].bookingdates = checkin: '#(date())', checkout: '#(date())'
* def result = call read('createrecord.feature') PayLoad: #(payload) , URL: #(baseURL)

######################################
createrecord.feature file will have

@ignore
Feature: To create data

Background:
* header Accept = 'application/json'

Scenario:
Given url __arg.URL
And path 'booking'
And request __arg.PayLoad
When method post
Then status 200


Here in createrecord.feature file how I can iterate through passed payload so that single payload will be passed to post request.










share|improve this question






























    1















    I am sending multiple arguments to .feature file one of the argument is request json payload generated by using karate table. How to iterate through request payload so that post request will get one payload at a time.



    Scenario: post booking

    * table payload
    | firstname | lastname | totalprice | depositpaid |
    | 'foo' | 'IN' | 10 | true |
    | 'bar' | 'out' | 20 | true |

    #date will calculate using js function in background and baseURL is configured in karate.config.js file

    * set payload[*].bookingdates = checkin: '#(date())', checkout: '#(date())'
    * def result = call read('createrecord.feature') PayLoad: #(payload) , URL: #(baseURL)

    ######################################
    createrecord.feature file will have

    @ignore
    Feature: To create data

    Background:
    * header Accept = 'application/json'

    Scenario:
    Given url __arg.URL
    And path 'booking'
    And request __arg.PayLoad
    When method post
    Then status 200


    Here in createrecord.feature file how I can iterate through passed payload so that single payload will be passed to post request.










    share|improve this question


























      1












      1








      1








      I am sending multiple arguments to .feature file one of the argument is request json payload generated by using karate table. How to iterate through request payload so that post request will get one payload at a time.



      Scenario: post booking

      * table payload
      | firstname | lastname | totalprice | depositpaid |
      | 'foo' | 'IN' | 10 | true |
      | 'bar' | 'out' | 20 | true |

      #date will calculate using js function in background and baseURL is configured in karate.config.js file

      * set payload[*].bookingdates = checkin: '#(date())', checkout: '#(date())'
      * def result = call read('createrecord.feature') PayLoad: #(payload) , URL: #(baseURL)

      ######################################
      createrecord.feature file will have

      @ignore
      Feature: To create data

      Background:
      * header Accept = 'application/json'

      Scenario:
      Given url __arg.URL
      And path 'booking'
      And request __arg.PayLoad
      When method post
      Then status 200


      Here in createrecord.feature file how I can iterate through passed payload so that single payload will be passed to post request.










      share|improve this question














      I am sending multiple arguments to .feature file one of the argument is request json payload generated by using karate table. How to iterate through request payload so that post request will get one payload at a time.



      Scenario: post booking

      * table payload
      | firstname | lastname | totalprice | depositpaid |
      | 'foo' | 'IN' | 10 | true |
      | 'bar' | 'out' | 20 | true |

      #date will calculate using js function in background and baseURL is configured in karate.config.js file

      * set payload[*].bookingdates = checkin: '#(date())', checkout: '#(date())'
      * def result = call read('createrecord.feature') PayLoad: #(payload) , URL: #(baseURL)

      ######################################
      createrecord.feature file will have

      @ignore
      Feature: To create data

      Background:
      * header Accept = 'application/json'

      Scenario:
      Given url __arg.URL
      And path 'booking'
      And request __arg.PayLoad
      When method post
      Then status 200


      Here in createrecord.feature file how I can iterate through passed payload so that single payload will be passed to post request.







      karate






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 14:14









      Shekhar PatilShekhar Patil

      396 bronze badges




      396 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          The simple rule you are missing is that if the argument to call is a JSON array (of JSON objects) it will iterate automatically.



          Read the docs carefully please: https://github.com/intuit/karate#data-driven-features



          So make this change:



          * def result = call read('createrecord.feature') payload


          And baseURL will be available in createrecord.feature so you don't need to worry about passing it.



          Note that this may not work: * set payload[*].bookingdates refer this answer: https://stackoverflow.com/a/54928848/143475






          share|improve this answer



























          • Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

            – Shekhar Patil
            Mar 29 at 6:13











          • @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

            – Peter Thomas
            Mar 29 at 12:31










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399782%2fhow-to-deserialize-json-payload-passed-to-other-feature-file-which-accept-multip%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          The simple rule you are missing is that if the argument to call is a JSON array (of JSON objects) it will iterate automatically.



          Read the docs carefully please: https://github.com/intuit/karate#data-driven-features



          So make this change:



          * def result = call read('createrecord.feature') payload


          And baseURL will be available in createrecord.feature so you don't need to worry about passing it.



          Note that this may not work: * set payload[*].bookingdates refer this answer: https://stackoverflow.com/a/54928848/143475






          share|improve this answer



























          • Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

            – Shekhar Patil
            Mar 29 at 6:13











          • @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

            – Peter Thomas
            Mar 29 at 12:31















          1
















          The simple rule you are missing is that if the argument to call is a JSON array (of JSON objects) it will iterate automatically.



          Read the docs carefully please: https://github.com/intuit/karate#data-driven-features



          So make this change:



          * def result = call read('createrecord.feature') payload


          And baseURL will be available in createrecord.feature so you don't need to worry about passing it.



          Note that this may not work: * set payload[*].bookingdates refer this answer: https://stackoverflow.com/a/54928848/143475






          share|improve this answer



























          • Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

            – Shekhar Patil
            Mar 29 at 6:13











          • @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

            – Peter Thomas
            Mar 29 at 12:31













          1














          1










          1









          The simple rule you are missing is that if the argument to call is a JSON array (of JSON objects) it will iterate automatically.



          Read the docs carefully please: https://github.com/intuit/karate#data-driven-features



          So make this change:



          * def result = call read('createrecord.feature') payload


          And baseURL will be available in createrecord.feature so you don't need to worry about passing it.



          Note that this may not work: * set payload[*].bookingdates refer this answer: https://stackoverflow.com/a/54928848/143475






          share|improve this answer















          The simple rule you are missing is that if the argument to call is a JSON array (of JSON objects) it will iterate automatically.



          Read the docs carefully please: https://github.com/intuit/karate#data-driven-features



          So make this change:



          * def result = call read('createrecord.feature') payload


          And baseURL will be available in createrecord.feature so you don't need to worry about passing it.



          Note that this may not work: * set payload[*].bookingdates refer this answer: https://stackoverflow.com/a/54928848/143475







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 14:31

























          answered Mar 28 at 14:23









          Peter ThomasPeter Thomas

          21.6k4 gold badges21 silver badges66 bronze badges




          21.6k4 gold badges21 silver badges66 bronze badges















          • Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

            – Shekhar Patil
            Mar 29 at 6:13











          • @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

            – Peter Thomas
            Mar 29 at 12:31

















          • Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

            – Shekhar Patil
            Mar 29 at 6:13











          • @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

            – Peter Thomas
            Mar 29 at 12:31
















          Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

          – Shekhar Patil
          Mar 29 at 6:13





          Thanks for your reply. Your suggestion is working fine. Just wondering in case if there is a need to pass multiple JSON payloads to another feature file. How the user has to deal with it. Or does the Karate not recommend to follow this approach. As in the above example __arg.PayLoad is passing an entire JSON object due to which post fails. Also, * set payload[*].bookingdates is working for me. However as mentioned in the answer provided in the above link, relying on this may be not feasible. So I have used 'set' instead 'table'.

          – Shekhar Patil
          Mar 29 at 6:13













          @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

          – Peter Thomas
          Mar 29 at 12:31





          @ShekharPatil any variable in scope is automatically available to called features. but please ask a new question (with a clear example) if needed

          – Peter Thomas
          Mar 29 at 12:31








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.




















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid …


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55399782%2fhow-to-deserialize-json-payload-passed-to-other-feature-file-which-accept-multip%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to preserve electronics (computers, tablets and phones) for hundreds of years Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) The network's official Twitter account is up and running again. What content…How might modern humans leave a message for 50,000 years?How would an aquatic race develop computers?How do we make computers care for human life?Keeping supplies for 1000 yearsWhat will cell phones become in 100 years?What body armor protects against a laser?Could a society attain 1800s technology if limited to using copper and bronze?Electricity power (magic) and electronicsScavenging metal resources in post-apocalypse after 100 yearsWhy would precursors create devices that can survive and still work after hundreds of years?

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해

          Convert JSON to MapSimplest way to convert a string representing JSON array into Java array List of key value pairsHow to take String JSON values into HashMapConvert a JSON String to a HashMapCreating BSON object from JSON stringJSONObject - How to get a value ?Better Map ConstructorReading JSON from Url javaUpdate columns if input values are not null otherwise ignore and keep the existing values of column in databaseHow to store object represented as Json string into Couchbase Lite?Go JSON into MapHow do I efficiently iterate over each entry in a Java Map?Sort a Map<Key, Value> by valuesHow to round a number to n decimal places in JavaCan comments be used in JSON?How do I read / convert an InputStream into a String in Java?How can I pretty-print JSON in a shell script?What is the correct JSON content type?How can I deserialize JSON to a simple Dictionary<string,string> in ASP.NET?Why does Google prepend while(1); to their JSON responses?Parse JSON in JavaScript?