I have CSV file (with around 300 rows) to read values which is passed in Json payload. On executing this test scenario for every CSV file's row, a new ID is generated in Json response i.e. response consist of an ID for each row present in CSV file.
Example: Id = 1 for CSV row 1 Id = 2 for CSV row 2 " " Id = n for CSV row n
Scenario Outline: Create new content value (using CSV file) for movie: <Movie> with Cast: <Cast>
When json payload = {'attributes':[{'entity_attribute_id': 41, 'value': '<Genre>'},{'entity_attribute_id': 42, 'value': '<Language>'},{'entity_attribute_id': 39, 'value': '<Movie>'},{'entity_attribute_id': 101,'value': '2020-12-03'}],'entity_type_id': '10'}
Given url baseUrl + postContentValues
And def cookie = read('content-cookie.txt')
And header cookie = cookie
And request payload
When method post
Then status 200
And print response
And def contentId = response.id
And print contentId
And def createdContentIdList = karate.append(contentId)
And print createdContentIdList
# And def createdContentIdList = karate.append(contentId)
# And def createdContentIdList = []
# And def fun = function(x){ karate.appendTo(createdContentIdList, x) }
# And karate.forEach(contentId, fun)
# And print createdContentIdList
Examples:
|read('RoughTable.csv')|
Scenario Outline: Pass contentID in URL
Given url baseUrl + getSpecificContentValue +'<contentValueId>' + '?client=web&'
When method get
Then status 200
And print response
Examples:
|contentValueId|
|contentId |
If I use karate.append() or karate .appendTo(), Following createdContentIdList is generated (which is incorrect):
Now,I want to create an array (named ContentID) which has all row's IDs like ContentID = [1,2,3,....n]
And Pass the content id one by one to next api's url.
How can I do this in Karate ?
Thanks in advance !!