Really New to Postman, trying to make creating bulk data as easy as populating csv and running request - Cannot figure out how to skip/ignore request line if Variable is blank as it being “” appears to break the iteration and the user is not created
E.g. In request ‘RoleID1’, ‘RoleID2’ and ‘RoleID3’ may not all be required as such RoleID3 for example may need to be skipped as trying to Post with RoleID3 being blank (see Screenshot of spreadsheet) results in the user entry not being created
Not sure what the expected structure would be (really new so not surebut if you can advise where I would find this I can try get it), just need it to skip/ignore the role line(s) if the variable is blank/null so that the user is created with all other applicable roles and the blank/null ones dont block creation
Yup, same for if RoleID1 or RoleID2 are empty etc. all other fields will always be populated so just need the RoleID rows to be removed/ignored if the variable in the row is blank/null
Looks like that worked perfectly thank you!, I assume to expand that for additional role entries its as simple as expanding the pre-request script with an additional line for say RoleID4? like so:
Building onto this further, what would the simplest way to have it ignore “role” entirely if all RoleIDs are blank is that possible using what we have?
Ah awesome, so to make sure I understand what its doing there, prerequest is setting rolelist to empty - its then checking if the data from the sheet is NOT empty, NOT undefined, NOT null and then pushing the string of ‘{ “href”: “/roles/{{RoleID1}}” }’ etc into the rolelist variable otherwise its nulling it if it fits any of the above checks (empty / null etc )
Then the bottom line is checking if roleList has any length, if it does its then setting the string of role variable to “role”:“roleList String” where as if it has no length in roleList its setting it to { }