我有一个表单,其中一个字段是 IS_JSON 类型
db.define_table('vmPowerOpsTable',
Field('launchId',label=T('Launch ID'),default =datetime.datetime.now().strftime("%d%m%y%H%M%S")),
Field('launchDate',label=T('Launched On'),default=datetime.datetime.now()),
Field('launchBy',label=T('Launched By'),default = auth.user.email if auth.user else "Anonymous"),
Field('inputJson','text',label=T('Input JSON*'),
requires = [IS_NOT_EMPTY(error_message='Input JSON is required'),IS_JSON(error_message='Invalid JSON')]),
migrate=True)
当用户提交这个Form时,这个数据也同时被插入到另一个表中。
db.opStatus.insert(launchId=vmops_launchid,launchDate=vmops_launchdate
,launchBy=vmops_launchBy,opsType=operation_type,
opsData=vmops_inputJson,
statusDetail="Pending")
db.commit()
现在从调度程序中,我正在尝试检索这些数据并发出 POST 请求。
vm_power_opStatus_row_data = vm_power_opStatus_row.opsData
请注意,在上述步骤中,我能够检索数据。(我将它插入数据库并看到该字段与用户输入的内容完全匹配。
然后从调度程序,我做一个 POST。
power_response = requests.post(vm_power_op_url, json=vm_power_opStatus_row_data)
POST 请求由我的控制器中的一个函数处理。
控制器功能:
@request.restful()
def vmPowerOperation():
response.view = 'generic.json'
si = None
def POST(*args, **vars):
jsonBody = request.vars
print "Debug 1"+ str(jsonBody) ##-> Here it returns blank in jsonBody.
但是,如果我从外部(POSTMAN 客户端甚至 python 请求)发出相同的请求,我会得到想要的结果。
当我尝试从表中获取数据类型时,数据类型有什么问题吗?