I am new to Benthos and trying to learn how it works. I am trying to input a JSON file with some key:value pairs, add a new field and POST that new field to get a response.
pipeline:
processors:
- mapping: |
root.id = this.id
root.submitName = "testingAcc"
root.cost = this.cost
let idLen = root.id.length()
let nameLen = root.submitName.length()
root.send = $idLen + root.id + $nameLen + root.submitName + this.cost
- branch:
request_map: |
root = this.send
processors:
- http:
url: "<http link>"
verb: POST
result_map: |
root.response = this.content().string()
Example
Input = {"id": "1", "cost": "500"} Mapping = {"id": "1", "submitName": "testingAcc", "cost": "500", "send": "1110testingAcc500"}
Value that sends via POST = 1110testingAcc500
Branch = {"id": "1", "submitName": "testingAcc", "cost": "500", "send": "1110testingAcc500", "response": "OK"}
However, when I run this I get an error saying that the request_map line (root = this.send
) did not find the expected key. I thourght this would work as I mapped the send value so it could be referenced in the branch processor. I have tried different ways to call the keyword (like root = this.send
, root = root.send
, etc.) but all the same error.
Hopefully I explained this well. I tried googling the error and reading documentation but couldn't find an answer or any examples to help me understand. Any help would be greatly appreciated!