Hi there,
I’m struggling with postman collection branching scripts.
I have three tests that I need to run.
- Login
- Get a Bookshelf of that user
- Get the course content of that bookshelf
- Get the levels of the course content from step 3 request
This is what I have
- Login
{{ENV_URL}}/api/mee/login - GetBookShelf
{{ENV_URL}}/api/mee/bookshelf?pageIndex={{PageIndex}}&pageSize={{PageSize}} - GetCourseData
{{ENV_URL}}/api/mee/coursedata?projectId={{ProjectID}} - GetCourseDatawithLevelID
{{ENV_URL}}/api/mee/coursedata?projectId={{ProjectID}}&levelID={{LevelID}}
As you can see the parameters are being passed through each request. Request 2 extracts {{ProjectID}}, Request 3 needs {{ProjectID}} to extract {{LevelID}} content. Is there a way to do this, by storing and capturing variables within Request calls?
I’m struggling with 2nd and 3rd request.
For request: GetBookShelf, the JSON body response returns more than one ProjectIds for some Login users. I would like to store that ProjectID in a variable, eg: ProjectID_1, ProjectID_2, ProjectID_3, etc… as I’ve done here:
On the GetCourseData request, I’m iterating through total categories, to loop and return the CategoryIds (same as LevelIds for the next request), I’d like to store these Category IDs in a variable
Once I get the LevelIDs and its ProjectIDs in local variables, I’d like to call the same request with another parameter being passed into the request url, i.e. the LevelID.
What is the best approach to call these requests with the parameters being retrieved from JSON response and variables set? any help appreciated.
Many thanks,
Ray