As your individual response come through, you can create a list of the values using extend
(vs append
). Then create your final dictionary.
Here’s a mockup of one way to implement -collect all the response, then iterate over the list. Otherwise you can parse each response as they come in.
response1 = { "@odata.context": "https://example.com/services/api/x/odata/api/views/$metadata#vw_rpt_review_response_comment", "value": [ { "pr_comment_id": 1, "pr_comment": "Test Comment" }, { "pr_comment_id": 2, "pr_comment": "Test Comment" }, { "pr_comment_id": 3, "pr_comment": "Test Comment" } ],
"@odata.nextLink": "https://example.com/services/api/x/odata/api/views/$metadata#vw_rpt_review_response_comment?$skip=1000"
}
response2 = { "@odata.context": "https://example.com/services/api/x/odata/api/views/$metadata#vw_rpt_review_response_comment", "value": [ { "pr_comment_id": 4, "pr_comment": "Test Comment" }, { "pr_comment_id": 5, "pr_comment": "Test Comment" }, { "pr_comment_id": 6, "pr_comment": "Test Comment" } ],
"@odata.nextLink": "https://example.com/services/api/x/odata/api/views/$metadata#vw_rpt_review_response_comment?$skip=2000"
}
value_list = []
for resp in [response1, response2]:
# print(resp['value'])
value_list.extend(resp['value'])
my_dict = {'value': value_list}
my_dict
Output
{'value': [{'pr_comment_id': 1, 'pr_comment': 'Test Comment'},
{'pr_comment_id': 2, 'pr_comment': 'Test Comment'},
{'pr_comment_id': 3, 'pr_comment': 'Test Comment'},
{'pr_comment_id': 4, 'pr_comment': 'Test Comment'},
{'pr_comment_id': 5, 'pr_comment': 'Test Comment'},
{'pr_comment_id': 6, 'pr_comment': 'Test Comment'}]}
3
solved Python code to Download Specific JSON key value data through REST API calls