我想将“ is_app_enabled”更改为true,以适应特定的过滤市场, 声明:查询特定市场,然后将is_app_enabled的值更改为true, 我收到的网络请求如下:
General:
Request URL: http://10.76.98.167:5000/api/v1/apps/settings/dcp/
Request Method: PUT
Status Code: 200 OK
Remote Address: 10.76.98.167:5000
Referrer Policy: no-referrer-when-downgrade
Response Headers
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://10.76.98.167:5000
Cache-Control: no-store
Connection: keep-alive
Content-Length: 16
Content-Type: application/json
csrf-token: 8303a69ba4cfe891e7595f15b76f9ecfed1e2c96f75349533dae12faf2460248
Date: Mon, 01 Apr 2019 09:53:36 GMT
Server: nginx/1.15.0
Set-Cookie: session=.eJyrVopPK0otzlCyKikqTdVRis9MUbKqVlJIUrJSisryrPR18azyzQ018XcPNIzMSjbyzcrI9HVJN_J3yTbxcwk19A_xNPY1CrVVqgXqLUgtyk3MS80rgZlWWpxaBDZRKTEvMaeyJDO5WKkWAFXsJa0.D4NxIA.3hVVx9L-fUj7hAePOz4-aXWY3eQ; Expires=Mon, 01-Apr-2019 10:23:36 GMT; HttpOnly; Path=/
X-Frame-Options: SAMEORIGIN
Requests Headers:
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Content-Length: 72
Content-Type: application/json;charset=UTF-8
Cookie: session=.eJyrVopPK0otzlCyKikqTdVRis9MUbKqVlJIUrJSisryrPR18azyzQ018XcPNIzMSjbyzcrI9HVJN_J3yTbxcwk19A_xNPY1CrVVqgXqLUgtyk3MS80rgZlWWpxaBDZRKTEvMaeyJDO5WKkWAFXsJa0.D4Nw3A.9lXgT0AhT5QFmmK6HJK9_G7aTTg
csrf-token: 8303a69ba4cfe891e7595f15b76f9ecfed1e2c96f75349533dae12faf2460248
Host: 10.76.98.167:5000
Origin: http://10.76.98.167:5000
Referer: http://10.76.98.167:5000/explorer/v2/index.html
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
Request Payload :
{query: "market == 'Austin'", is_app_enabled: true, tz: "Asia/Kolkata"}
is_app_enabled: true
query: "market == 'Austin'"
tz: "Asia/Kolkata"
我尝试使用以下代码:
import requests
import json
s=requests.session()
report_url= 'http://10.76.98.167:5000/api/v1/apps/settings/dpo/'
payload = {query: "market == 'DEL'", is_app_enabled: true, tz: "Asia/Kolkata"}
r = s.post(report_url,data=paylaod)
print("second",report_url)
抛出错误:有效载荷=‘{query:“ market =='DEL'”,is_app_enabled:true,tz:“ Asia / Kolkata”} NameError:未定义名称“查询”,
如何查询数据并更新特定字段?
答案 0 :(得分:0)
这是因为没有引号,而是将其视为未定义的变量。尝试:
payload = {"query": "market == 'DEL'",
"is_app_enabled": "true",
"tz": "Asia/Kolkata"}
另外,请在此处检查payload
的拼写:
r = s.post(report_url,data=paylaod)