Multiple Requests - combining GET requests

Hi,

I’ve run into a snag with setting up multiple calls in one Communications tab.

The idea behind this custom module:

  • Fetch the files attached to an object (client, sales order, etc) in our ERP,
  • Get the binary data and the name to show up in the interface,
  • Used by the next module for either downloading or uploading the files.

How it should work:

  1. The first call to get an array of files. This response’s {{body}} is an array, so I iterate on it, to get the fields.
    => This works, when I change the “temp” to “output”

  2. The second call is to the files’ URL’s. We need the binary data, which this call pushes to its response {{body}}.
    => This doesn’t work. The temp.fileURL is empty (undefined), even though I can see it when I don’t use the second call.

The 2 calls:

[
	{
	"url": "{{parameters.module}}/{{parameters.objectId}}/documents",
	"method": "GET",
	"headers": {
			"Authorization": "Basic {{base64(connection.username + ':' + connection.password)}}"
		},
	"response": {
		"iterate": "{{body}}",
        "temp":{
            "file_url":"{{item.url}}",
            "file_name":"{{item.name}}",
            "file_id":"{{item.id}}",
            "content_type":"{{item.contentType}}",
            "data":"{{item}}"}
    }
	},
	{
	"url": "{{temp.file_url}}",
	"headers": {
			"Authorization": "Basic {{base64(connection.username + ':' + connection.password)}}"
		},
	"method": "GET",
	"response": {
		"output": {
			"file_data":"{{body}}",
            "file_url":"{{temp.file_url}}",
            "file_name":"{{temp.file_name}}",
            "file_id":"{{temp.file_id}}",
            "content_type":"{{temp.content_type}}",
            "data":"{{temp}}"}
		}
    }
]

A side note, I’ve tried this both in an Action and a Search custom module.

I’ve also tried this with an RPC in the mappable parameters, but that didn’t work as the user would have to chose one of the documents, which would result in an odd UX.

Would love some help with this one!

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