I have tried just about all permutations of quotes Code 1 below is the hardcoded values even this fails with error 400 loaddata =""" { "Application":"EssbaseHPA" , "db": "PerformanceData", "jobtype":"dataload", "Parameters": { "rule":"PerfromanceData.rul", "file":"DPerformanceData.txt", "abortOnError": "false" } } """
Code 2 is what I am trying to get to work. Vars are appname,dbname.datafile
loaddata1= "{"Application": appname ,"db":dbname, "parameters":"{ parameters':"file":datafile,"abortOnError":false"}"}"
The above gives unrecognized token appname
Thanks
CodePudding user response:
You could try it like this:
import json
appname = "hallo"
dbname = "stgres"
a = {
"Application": appname,
"db": dbname,
"jobtype": "dataload",
"Parameters": {
"rule": "PerformanceData.rul",
"file":"DPerformanceData.txt",
"abortOnError": "false"
}
}
json_a = json.dumps(a, indent=4)
print(json_a)
CodePudding user response:
Thanks, gave me an idea on another permutation: Below. I had to build up payload with the vars appname, dbname, datafile below: ldata = "{"application":"" appname ""," ldata = ldata ""db":"" dbname "", "jobtype":"dataload"," ldata = ldata ""parameters": { "file":"" datafile ""," ldata = ldata ""loaddata":"true", "abortOnError":"false"} }" - The key again is the spacing between "parameters": { Need to have a space on both side of the {.
The escaping for " can cause one to go blind.