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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript