I am trying to read the data from a file that has content that looks like this
{"name": "Host1","type": "ipmask","subnet": ["0.0.0.0","255.255.255.255"],"dynamic_mapping": None},
{"name": "Host2","type": "ipmask","subnet": ["0.0.0.0","255.255.255.255"],"dynamic_mapping": None},
into a variable in python so that I can use it in the code below for a post request using JSON.
with open('data.txt', 'r') as file:
dat2 = file.read()
post2 = {
"id": 5,
"method": "set",
"params": [
{
"data": [
dat2
],
"url": "/config/url"
},
"session": sessionkey,
"verbose": 1
}
I'm stuck because when I copy and past the data into the JSON where dat2 is, the request goes through sucessfully. I really don't understand what I am doing wrong, I have even tried stripping newlines and whitepaces. If anyone could help I would greatly appreciate it.