Using the API to create new routes
How can I use the Stream REST API to create new routes? The API doc reference doesn’t show a POST but I do see a PATCH. Is PATCH the operation I should use? Can someone provide an example payload by chance?
Best Answer
-
You can create routes in Stream by utilizing this endpoint using the PATCH method, e.g.
http://localhost:19000/api/v1/m/default/routes/default
A sample payload could be:
{'id': 'random456', 'routes': [ {'id': 'random123', 'name': 'Route 1234', 'final': True, 'disabled': False, 'pipeline': 'main', 'description': 'hello, i was created by the API', 'clones': [], 'enableOutputExpression': False, 'filter': 'true', 'output': 'default'} ]}
Note that this may overwrite the existing routes, so please take the necessary steps to export them. This can be done manually in the UI, or via the API by using the GET method on the /routes endpoint. You could also build functionality in a script to:
- call the GET method on the /routes endpoint
- take the JSON returned from the call and add the new route JSON to it (e.g. a new JSON object in the ‘routes list in the example above)
- call the PATCH method and send the new JSON
0
Answers
-
You can create routes in Stream by utilizing this endpoint using the PATCH method, e.g.
http://localhost:19000/api/v1/m/default/routes/default
A sample payload could be:
{'id': 'random456', 'routes': [ {'id': 'random123', 'name': 'Route 1234', 'final': True, 'disabled': False, 'pipeline': 'main', 'description': 'hello, i was created by the API', 'clones': [], 'enableOutputExpression': False, 'filter': 'true', 'output': 'default'} ]}
Note that this may overwrite the existing routes, so please take the necessary steps to export them. This can be done manually in the UI, or via the API by using the GET method on the /routes endpoint. You could also build functionality in a script to:
- call the GET method on the /routes endpoint
- take the JSON returned from the call and add the new route JSON to it (e.g. a new JSON object in the ‘routes list in the example above)
- call the PATCH method and send the new JSON
0