Empty list in result of RPC Procedure call

Hi I have a problem with Remote Procedure. I defined the communication:

{
  "url": "/v3/countries.json",
  "method": "GET",
  "headers": {
    "X-inFakt-ApiKey": "{{connection.apiKey}}"
  },
  "response": {
    "output": {
      "label": "{{item.english_name}}",
      "value": "{{item.alpha_2}}"
    },
    "iterate": "{{body.entities}}"
  }
}

body from this endpoint is like this:

{
	"metainfo": {
		"count": 10,
		"total_count": 217,
		"next": "https://api.infakt.pl/api/v3/countries.json?offset=10&limit=10",
		"previous": "https://api.infakt.pl/api/v3/countries.json?offset=0&limit=10"
	},
	"entities": [
		{
			"id": 1,
			"alpha_2": "AF",
			"alpha_3": "AFG",
			"english_name": "Afghanistan",
			"polish_name": "Afganistan",
			"continent": "Azja",
			"european_union": false,
			"currency": "AFN"
		},
		{
			"id": 3,
			"alpha_2": "AL",
			"alpha_3": "ALB",
			"english_name": "Albania",
			"polish_name": "Albania",
			"continent": "Europa",
			"european_union": false,
			"currency": "ALL"
		},
		{
			"id": 4,
			"alpha_2": "DZ",
			"alpha_3": "DZA",
			"english_name": "Algeria",
			"polish_name": "Algieria",
			"continent": "Afryka",
			"european_union": false,
			"currency": "DZD"
		},
		{
			"id": 6,
			"alpha_2": "AD",
			"alpha_3": "AND",
			"english_name": "Andorra",
			"polish_name": "Andora",
			"continent": "Europa",
			"european_union": false,
			"currency": "EUR"
		},
		{
			"id": 7,
			"alpha_2": "AO",
			"alpha_3": "AGO",
			"english_name": "Angola",
			"polish_name": "Angola",
			"continent": "Afryka",
			"european_union": false,
			"currency": "AOA"
		},
		{
			"id": 8,
			"alpha_2": "AI",
			"alpha_3": "AIA",
			"english_name": "Anguilla",
			"polish_name": "Anguilla",
			"continent": "Ameryka Północna",
			"european_union": false,
			"currency": "XCD"
		},
		{
			"id": 10,
			"alpha_2": "AG",
			"alpha_3": "ATG",
			"english_name": "Antigua and Barbuda",
			"polish_name": "Antigua i Barbuda",
			"continent": "Ameryka Północna",
			"european_union": false,
			"currency": "XCD"
		},
		{
			"id": 195,
			"alpha_2": "SA",
			"alpha_3": "SAU",
			"english_name": "Saudi Arabia",
			"polish_name": "Arabia Saudyjska",
			"continent": "Azja",
			"european_union": false,
			"currency": "SAR"
		},
		{
			"id": 11,
			"alpha_2": "AR",
			"alpha_3": "ARG",
			"english_name": "Argentina",
			"polish_name": "Argentyna",
			"continent": "Ameryka Połudiowa",
			"european_union": false,
			"currency": "ARS"
		},
		{
			"id": 12,
			"alpha_2": "AM",
			"alpha_3": "ARM",
			"english_name": "Armenia",
			"polish_name": "Armenia",
			"continent": "Azja",
			"european_union": false,
			"currency": "AMD"
		}
	]
}

When I test this RPC or when I hook it up with my parameter in module the list is empty -

Hi @PL ,
I guess the problem could be that the url lacks a hostname. What happens when you change it from /v3/countries.json to https://do9gw.mocklab.io/v3/countries.json?

Anyways, here is a blueprint showing that the list of entities is populated.
blueprint.json (9.7 KB)

@zezutom The base URL is defined in BASE.

Anyway I made it work however I don’t remember how. Maybe there was something wrong with the connection.

This works:
BASE:

{
	"baseUrl": "https://api.infakt.pl",
	"response": {
		"output": "{{body}}",
        "error": {
           	"message": "{{getErrorMessage(statusCode, body)}}"
        }
    },
	"log": {
		"sanitize": ["request.headers.authorization"]
	}
}

Connection:

{
	"url": "https://api.infakt.pl/v3/invoices.json",
	"headers": {
		"X-inFakt-ApiKey": "{{parameters.apiKey}}"
	},"response": {
        "error": {
           "message": "{{body.error}}"
        },
        "type": "json"
    },
	"log": {
		"sanitize": ["request.headers.X-inFakt-ApiKey"]
	}
}

RPC:

{
  "qs": {
    "limit": 300,
    "offset": 0
  },
  "url": "/v3/countries.json",
  "method": "GET",
  "headers": {
    "X-inFakt-ApiKey": "{{connection.apiKey}}"
  },
  "response": {
    "limit": 300,
    "output": {
      "label": "{{item.english_name}}",
      "value": "{{item.alpha_2}}"
    },
    "iterate": "{{body. Entities}}"
  }
}
1 Like