Flow Assistance

Hey Guys,

I have been struggling to piece this together. I am doing an API query to get a list documents that includes an id, client_id and label. I need to take each object and do a lookup of the client_id to get the name and include it going forward.

Once I have that on each object then loop through for each object lookup that customer name via another API query and get a client_id and then put a query with data with that id and the document information.

This is kind of hard to explain but I have all the data and can manually move the document over but unsure the best way to tie it all together to automate moving these documents.

Any help would be great on this.

Best to take it one step at a time.

First lets see the initial data returned by the first api, then explain what you mean by lookup, database or in the initial data etc.
Please supply data in a text copyable format abd use the </> button when posting code/json.

p.s. Limit the data to a handleable size, as we only need a small sample to test.

This would be the starting data about 150+ documents. This would be followed by a query to the API to find out client_id=customer name. Then get the document information which is an API query to the id. This result plus the customer name would be used in the next phase.

The client_id we would need to do a lookup API to query to find out what the name is.

[
  {
    "id": 8082201,
    "organization_id": 3555,
    "label": "Customer Technical Document",
    "description": "",
    "client_id": 654402,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  },
  {
    "id": 7920672,
    "organization_id": 3555,
    "label": "Customer Name - Customer Technical Document",
    "description": "",
    "client_id": 654405,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  },
  {
    "id": 7467187,
    "organization_id": 3555,
    "label": "Customer Name - Customer Technical Document",
    "description": "",
    "client_id": 654411,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  },
  {
    "id": 8041228,
    "organization_id": 3555,
    "label": "Customer Name - Customer Technical Document",
    "description": "",
    "client_id": 654099,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  },
  {
    "id": 7818583,
    "organization_id": 3555,
    "label": "Customer Name - Customer Technical Document",
    "description": "",
    "client_id": 1210958,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  },
  {
    "id": 7743376,
    "organization_id": 3555,
    "label": "Customer Name - Customer Technical Document",
    "description": "",
    "client_id": 654435,
    "customId": "",
    "templateId": 16720,
    "templateName": "Customer Technical Document ",
    "type": "custom"
  }
]

Ok can you show the api call to get names.

The first part to spilt the data and send a http request to get names would be some thing like this. I moved the payloads to data as the http request will overwrite payload.

[{"id":"b8fbdf3c0c93f313","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[   {     \"id\": 8082201,     \"organization_id\": 3555,     \"label\": \"Customer Technical Document\",     \"description\": \"\",     \"client_id\": 654402,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   },   {     \"id\": 7920672,     \"organization_id\": 3555,     \"label\": \"Customer Name - Customer Technical Document\",     \"description\": \"\",     \"client_id\": 654405,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   },   {     \"id\": 7467187,     \"organization_id\": 3555,     \"label\": \"Customer Name - Customer Technical Document\",     \"description\": \"\",     \"client_id\": 654411,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   },   {     \"id\": 8041228,     \"organization_id\": 3555,     \"label\": \"Customer Name - Customer Technical Document\",     \"description\": \"\",     \"client_id\": 654099,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   },   {     \"id\": 7818583,     \"organization_id\": 3555,     \"label\": \"Customer Name - Customer Technical Document\",     \"description\": \"\",     \"client_id\": 1210958,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   },   {     \"id\": 7743376,     \"organization_id\": 3555,     \"label\": \"Customer Name - Customer Technical Document\",     \"description\": \"\",     \"client_id\": 654435,     \"customId\": \"\",     \"templateId\": 16720,     \"templateName\": \"Customer Technical Document \",     \"type\": \"custom\"   } ]","payloadType":"json","x":70,"y":3280,"wires":[["12c083bcda0014a2"]]},{"id":"12c083bcda0014a2","type":"split","z":"65617ffeb779f51c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":190,"y":3280,"wires":[["43a85b8dd068f42c"]]},{"id":"43a85b8dd068f42c","type":"delay","z":"65617ffeb779f51c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"4","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":330,"y":3280,"wires":[["68c3533ed35bbf7d"]]},{"id":"68c3533ed35bbf7d","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"data","tot":"msg"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"url","pt":"msg","to":"\"http://example.com?id=\" & $$.data.client_id","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3280,"wires":[["578e0ba9942b4249","ccb8ad3b40f8899d"]]},{"id":"578e0ba9942b4249","type":"debug","z":"65617ffeb779f51c","name":"url","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"url","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":3260,"wires":[]},{"id":"ccb8ad3b40f8899d","type":"http request","z":"65617ffeb779f51c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":3340,"wires":[["901d46811e55754a"]]},{"id":"901d46811e55754a","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"data.name","pt":"msg","to":"payload.name","tot":"msg"},{"t":"move","p":"data","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":3340,"wires":[["eb5791a303f93fa8","cd5600d365cc86d0"]]},{"id":"eb5791a303f93fa8","type":"debug","z":"65617ffeb779f51c","name":"payload name","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":3340,"wires":[]},{"id":"cd5600d365cc86d0","type":"join","z":"65617ffeb779f51c","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":3400,"wires":[["537fd33757cdbe4f"]]},{"id":"537fd33757cdbe4f","type":"debug","z":"65617ffeb779f51c","name":"joined payloads","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":720,"y":3400,"wires":[]}]

I will not repost the inject node as do not want to keep poasting the data, so add the inject node to any further example flows i post.

Please see customer data from the API call.

[
  {
    "id": 664990,
    "name": "Customer 1"
  },
  {
    "id": 1279011,
    "name": "Customer 2"
  },
  {
    "id": 1279210,
    "name": "Customer 3"
  },
  {
    "id": 653976,
    "name": "Customer 4"
  },
  {
    "id": 653979,
    "name": "Customer 5"
  }
]

Please be specific, where in my example flow is the data from, debug node number please

Here is a fuller example of how to move the first api data from the payload and save to data, then reset the headers before moving to next api call.
hope it helps

[{"id":"b8fbdf3c0c93f313","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"id\":8082201,\"organization_id\":3555,\"label\":\"Customer Technical Document\",\"description\":\"\",\"client_id\":654402,\"customId\":\"\",\"templateId\":16720,\"templateName\":\"Customer Technical Document \",\"type\":\"custom\"}]","payloadType":"json","x":70,"y":3260,"wires":[["12c083bcda0014a2"]]},{"id":"12c083bcda0014a2","type":"split","z":"65617ffeb779f51c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":190,"y":3260,"wires":[["43a85b8dd068f42c"]]},{"id":"43a85b8dd068f42c","type":"delay","z":"65617ffeb779f51c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"4","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":330,"y":3260,"wires":[["68c3533ed35bbf7d"]]},{"id":"68c3533ed35bbf7d","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"data","tot":"msg"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"url","pt":"msg","to":"\"http://example.com?id=\" & $$.data.client_id","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":3260,"wires":[["578e0ba9942b4249","109185722905b64b"]]},{"id":"578e0ba9942b4249","type":"debug","z":"65617ffeb779f51c","name":"url","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"url","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":3240,"wires":[]},{"id":"109185722905b64b","type":"change","z":"65617ffeb779f51c","name":"simulate api","rules":[{"t":"set","p":"payload","pt":"msg","to":"{     \"id\": 1279000 + $floor($random()*1000),     \"name\": \"Customer \" & $string($floor($random()*100))   }","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":170,"y":3320,"wires":[["901d46811e55754a"]]},{"id":"901d46811e55754a","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"data.name","pt":"msg","to":"payload.name","tot":"msg"},{"t":"set","p":"data.name_id","pt":"msg","to":"payload.id","tot":"msg"},{"t":"set","p":"url","pt":"msg","to":"\"http://example.com?id=\" & $$.data.api_id","tot":"jsonata"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":3320,"wires":[["eb5791a303f93fa8","36a1d6dd4314ed2f"]]},{"id":"ccb8ad3b40f8899d","type":"http request","z":"65617ffeb779f51c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":190,"y":3360,"wires":[["901d46811e55754a"]]},{"id":"eb5791a303f93fa8","type":"debug","z":"65617ffeb779f51c","name":"payload name api","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":3280,"wires":[]},{"id":"36a1d6dd4314ed2f","type":"change","z":"65617ffeb779f51c","name":"simulate api","rules":[{"t":"set","p":"payload","pt":"msg","to":"{     \"id\": 1279000 + $floor($random()*1000),     \"doc\": \"doc/ \" & $string($floor($random()*100))   }","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":3320,"wires":[["3c87743ae2bb7bf2"]]},{"id":"3c87743ae2bb7bf2","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"data.doc","pt":"msg","to":"payload.doc","tot":"msg"},{"t":"move","p":"data","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":3320,"wires":[["cd5600d365cc86d0","e17479ce6011522c"]]},{"id":"c6af55aee3ac531c","type":"http request","z":"65617ffeb779f51c","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":590,"y":3360,"wires":[["3c87743ae2bb7bf2"]]},{"id":"cd5600d365cc86d0","type":"join","z":"65617ffeb779f51c","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":3400,"wires":[["537fd33757cdbe4f"]]},{"id":"e17479ce6011522c","type":"debug","z":"65617ffeb779f51c","name":"payload doc api","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":960,"y":3280,"wires":[]},{"id":"537fd33757cdbe4f","type":"debug","z":"65617ffeb779f51c","name":"joined payloads","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":820,"y":3460,"wires":[]}]

[edit] Added further example with simulated api returns.

Sorry I thought you meant some of the results I already had. I forgot to mention the API is msg.payload.results I am trying to adjust to plug this in real quick.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.