Jun-05-2022, 05:24 AM
Hi
Objective: How to loop through over curl statement and 'put' key and value into curl put statement
Input: This is my sql query output in json format. for example I mentioned two columns here.
in next iteration in url it should pass "brand_name" and values as "Electra"
How to acheive this ?
Objective: How to loop through over curl statement and 'put' key and value into curl put statement
Input: This is my sql query output in json format. for example I mentioned two columns here.
[{'brand_id': 1, 'brand_name': 'Electra'}]I am using code all below for API call
import http.client conn = http.client.HTTPSConnection("circleci.com") payload = "{\"value\":\"xxxxxxxxxxxxxx\"}" headers = { 'content-type': "application/json", 'Circle-Token': "$CIRCLE_TOKEN" } conn.request("PUT", "/api/v2/${contextid}/environment-variable/xxxxxxxxxx", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))Now, brand_id which is first key in my json output should be passed as url dynamically in loop one bye one i.e first iteration its brand_id in url and '1' as value in --data section
in next iteration in url it should pass "brand_name" and values as "Electra"
How to acheive this ?