需要将多个变量传递给 payload 变量
Need to pass multiple variables to payload variables
我正在尝试使用格式 & +str(Var)+ 将多个变量传递给有效载荷,但我没有得到预期的输出。我在文件中有主机名并获取密码作为输入,并想将其传递给有效负载。
我收到与 "Error while parsing JSON payload or an incompatible argument type for the requested resource"
相关的错误
for x in content:
url='https://url/a/b/c/{}'.format(x.strip())
payload=('{{"ip-address": "x.x.x.x","user-name": "john","password": "'+ str(Pass) +'","db-name": "'+ str(x.strip()) +'","service-name": "y","port": "y","connection-string": "y"}}')
response = req.post(url,json=payload,headers=add_cookie,verify=False)
======================
for x in content:
url='https://url/a/b/c/{}'.format(x.strip())
payload={"ip-address": "x.x.x.x","user-name": "john","password": "{}","db-name": "{}","service-name": "y","port": "y","connection-string": "y"}.format(Pass, x.strip())
response = req.post(url,json=payload,headers=add_cookie,verify=False)
在第一部分你的负载是一个字符串而不是一个字典,它应该是
payload={"ip-address": "x.x.x.x","user-name": "john","password": str(Pass),"db-name": str(x.strip()),"service-name": "y","port": "y","connection-string": "y"}
在第二个中,您在 dict 类型上使用了格式函数,这是错误的。
我正在尝试使用格式 & +str(Var)+ 将多个变量传递给有效载荷,但我没有得到预期的输出。我在文件中有主机名并获取密码作为输入,并想将其传递给有效负载。
我收到与 "Error while parsing JSON payload or an incompatible argument type for the requested resource"
for x in content:
url='https://url/a/b/c/{}'.format(x.strip())
payload=('{{"ip-address": "x.x.x.x","user-name": "john","password": "'+ str(Pass) +'","db-name": "'+ str(x.strip()) +'","service-name": "y","port": "y","connection-string": "y"}}')
response = req.post(url,json=payload,headers=add_cookie,verify=False)
======================
for x in content:
url='https://url/a/b/c/{}'.format(x.strip())
payload={"ip-address": "x.x.x.x","user-name": "john","password": "{}","db-name": "{}","service-name": "y","port": "y","connection-string": "y"}.format(Pass, x.strip())
response = req.post(url,json=payload,headers=add_cookie,verify=False)
在第一部分你的负载是一个字符串而不是一个字典,它应该是
payload={"ip-address": "x.x.x.x","user-name": "john","password": str(Pass),"db-name": str(x.strip()),"service-name": "y","port": "y","connection-string": "y"}
在第二个中,您在 dict 类型上使用了格式函数,这是错误的。