import http.client
import json
conn = http.client.HTTPSConnection("{{apic}}")
payload = "payload{\r\n \"infraHPortS\": {\r\n \"attributes\": {\r\n \"dn\": \"uni/infra/accportprof-{{LEAF_INT_PROF}}/{{hports-PORT-1-typ-range}}\",\r\n \"name\": \"{{PORT-1}}\",\r\n \"rn\": \"{{hports-PORT-1-typ-range}}\",\r\n \"status\": \"created,modified\"\r\n },\r\n \"children\": [\r\n {\r\n \"infraPortBlk\": {\r\n \"attributes\": {\r\n \"dn\": \"uni/infra/accportprof-{{LEAF_INT_PROF}}/{{hports-PORT-1-typ-range}}/portblk-block2\",\r\n \"fromPort\": \"{{F-Port}}\",\r\n \"toPort\": \"{{T-Port}}\",\r\n \"name\": \"block2\",\r\n \"rn\": \"portblk-block2\",\r\n \"status\": \"created,modified\"\r\n },\r\n \"children\": []\r\n }\r\n },\r\n {\r\n \"infraRsAccBaseGrp\": {\r\n \"attributes\": {\r\n \"tDn\": \"uni/infra/funcprof/accbundle-{{VPC_HOST_POL_GRP}}\",\r\n \"status\": \"created,modified\"\r\n },\r\n \"children\": []\r\n }\r\n }\r\n ]\r\n }\r\n}"
headers = {
'Content-Type': 'application/json',
'Cookie': 'APIC-cookie=eyJhbGciOiJSUzI1NiIsImtpZCI6IjVyejc2MjViMWg1cnJyMGM3ejc5emhhbnAwdGV1YnoyIiwidHlwIjoiand0In0.eyJyYmFjIjpbeyJkb21haW4iOiJhbGwiLCJyb2xlc1IiOjAsInJvbGVzVyI6MX1dLCJpc3MiOiJBQ0kgQVBJQyIsInVzZXJuYW1lIjoiYWRtaW4iLCJ1c2VyaWQiOjE1Mzc0LCJ1c2VyZmxhZ3MiOjAsImlhdCI6MTYyNDY4MDY0NSwiZXhwIjoxNjI0NjgxMjQ1LCJzZXNzaW9uaWQiOiJSMmJwRXdPUVRKV0c3ZWhRcy93L1BBPT0ifQ.juzVBmDpEFblcGrPVm4K_ztY3QrDx_URtacJifEvHGMPTBgM3zsy_jXzvrNTXNZiK4QEB66BRETDrKucVVuIZOW5Q4hPqqemy4jsM-LnYOF2v1NEbWwkvu6uTDwLBcgvYeB8QOI4s6Mrr17emKVU_eMpSotZUh7CDhMkXUv7qOyGQZkWIqw4AF13BzyqiMHG6CmhY4PssInxVmwyCz_ubcgpnSKpMZcbaaJIWoUv-2-6EMnmqnlI-p1McnrLClYYezC-US7BpjXvxzJe123pPBZBgZ3-mV-ccEdKghEoRnPjjphjdSHKQDeTtx8R8cImBrDehBPCJC1wVDC785RgQA'
}
conn.request("POST", "/api/node/mo/uni/infra/accportprof-{{LEAF_INT_PROF}}/{{hports-PORT-1-typ-range}}.json", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Below is the Spreadsheet with the variables I am passing and it fails. If I pass the variables individually it works just doesn't work with csv.
Thanks,
Usha