Make HTTP requests in a for-in loop

Makes HTTP requests in a for-in loop.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

- getUserIDs:
    call: http.get
    args:
      url: https://example.com/getUserIDs
    result: userIds
- saveUserInfo:
    for:
      value: uid
      in: ${userIds}
      steps:
        - tryStep:
            try:
              steps:
                - get:
                    call: http.get
                    args:
                      url: ${"https://example.com/getUserInfo?userId=" + string(uid)}
                    result: userInfo
                - post:
                    call: http.post
                    args:
                      url: ${"https://example.com/saveUserInfo?userId=" + string(uid)}
                      body: ${userInfo}
            except:
              as: e
              steps:
                - knownErrors:
                    switch:
                      - condition: ${not("HttpError" in e.tags)}
                        return: '${"Connection problem with userID: " + string(uid)}'
                - unhandledErrors:
                    raise: ${e}

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.