Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

For Loop #114

Open
jgroom33 opened this issue Dec 13, 2018 · 2 comments
Open

For Loop #114

jgroom33 opened this issue Dec 13, 2018 · 2 comments

Comments

@jgroom33
Copy link
Collaborator

Possible implementation:

version: 2

requests:
  call1:
    request:
      url: https://postman-echo.com/time/now
      method: GET
  call2:
    request:
      url: https://jsonplaceholder.typicode.com/posts
      method: POST
      postData:
        mimeType: application/json
        text:
          foo: 2
  repeat_until:
    until:
      jsonpath: call1.content
      expect: <$ Env("STREST_GMT_DATE") $>
      else_goto: call1 # when false
      goto: call3 # when true
  call3:
    request:
      url: https://jsonplaceholder.typicode.com/posts
      method: POST
      postData:
        mimeType: application/json
        text:
          foo: 2
@jgroom33
Copy link
Collaborator Author

jgroom33 commented Feb 20, 2019

Another possible implementation:

version: 2

requests:
  call1:
    request:
      url: https://jsonplaceholder.typicode.com/posts
      method: GET
  call1Looper:
    loop: call1.content   # This is an array response from call1
    request:
      url: https://jsonplaceholder.typicode.com/posts/<$ this.id $>
      method: GET

This would be implemented similar to:

https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#standard-loops

@jgroom33
Copy link
Collaborator Author

third option:

version: 2

requests:
  call1:
    request:
      url: https://jsonplaceholder.typicode.com/posts
      method: GET
  call1.content.forEach(item):
    request:
      url: https://jsonplaceholder.typicode.com/posts/<$ item.id $>
      method: GET

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant