name = feature.getAttribute('Chain')
query = {'Name': name}
params = {'query': json.dumps(query), 'fields': 'Name,Id', "OrderBy": "Name", 'limit': 5}
r = requests.get('https://location.chainxy.com/api/Chains', params=params, headers=headers)
for whatever in json.loads(r.content)['Records']:
<space> chainid = whatever['Id']
<space> chainname = whatever['Name']
<space> feature.setAttribute('CXY Name', chainname)
<space> feature.setAttribute('CXY Id', chainid)
------------------------------------------------------------------------------------------
Let's say that my list has three items and I expect my output to be as the following but apparently, my for loop is overwriting my record so I only end up with one record instead of three. How can I fix this problem?
------------------------------------------------------------------------------------------
Expected Output
Record ID --- CXY Name --- CXY Id
1 --- Hello --- 87
1 --- Hi --- 88
1 --- Nice --- 100
Actual Output
Record ID CXY Name CXY Id
1 Nice 100