forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20-For-Loop-Call.yaml
More file actions
40 lines (39 loc) · 1.05 KB
/
20-For-Loop-Call.yaml
File metadata and controls
40 lines (39 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.2.json
#
# Tutorial: Loop and Call
#
# Iterates over the `fruits` array in the request body.
# Each element is sent as JSON to the fruitshop API.
#
# Expected input:
# {
# "fruits": [
# { "name": "Mango", "price": 1.23 },
# { "name": "Papaya", "price": 2.10 }
# ]
# }
#
# Try:
# curl -d @fruits.json -H "Content-Type: application/json" localhost:2000
#
# Verify results:
# https://api.predic8.de/shop/v2/products?limit=1000
# Search for: apricot, date, papaya
api:
port: 2000
flow:
- for:
# Evaluates to a list of Maps like [{ "name": "Mango", "price": 1.23 },..]
in: $.fruits
language: jsonpath
flow:
- setBody:
# Serialize the current item to a JSON string
value: ${toJSON(it)}
- call:
method: POST
url: https://api.predic8.de/shop/v2/products
- log:
message: "Created product: ${it['name']}"
- return:
status: 200