寻找一些自定义json样式语法请求的建议。
json.dumps
将格式化为:
{"tenantid": 1, "name": "NewRoleName", "users": "[djones]"}
但服务器需要这样的东西:
{"tenantid": 1, "name": "NewRoleName", "users": ["djones"]}
操纵双引号的简单方法是放在方括号中吗?
payload = {}
funcURL = "roles"
if name is not None: payload.update({'name': name})
if userStore is not None: payload.update({'userStore': userStore})
if users is not None: payload.update({'users': "[" + users + "]"})
if tenantid is not None: payload.update({'tenantid': tenantid})
if permissions is not None: payload.update({'userClaims': permissions})
print users
print payload
payload = json.dumps(payload)
return self._call_url('POST', funcURL, payload)
_call_url
使用请求发送有效负载:
response = requests.request( methodType, baseURL + "/" + funcURL, data=payload, headers=self.headers, timeout=timeout, verify=False)
答案 0 :(得分:0)
你试过了吗?
spinnerList.add(Html.fromHtml("NO<sub>2</sub> - maximum 1-hour concentration"));
如果Sub PrintArea()
Dim I As Integer
Dim ws As Worksheet
WS_Count = ActiveWorkbook.Worksheets.Count
For I = 1 To 6
Set ws = ThisWorkbook.Sheets(I)
ws.PageSetup.PrintArea = ws.Range("A1:Z24").Address
With ws.PageSetup
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
Next I
End Sub
类似于if users is not None: payload.update({'users': users})
答案 1 :(得分:0)
方括号表示一个列表。所以你必须把users
放到一个列表中:
funcURL = "roles"
payload = {}
if name is not None:
payload['name'] = name
if userStore is not None:
payload['userStore'] = userStore
if users is not None:
payload['users'] = [users]
if tenantid is not None:
payload['tenantid'] = tenantid
if permissions is not None:
payload['userClaims'] = permissions
payload = json.dumps(payload)
return self._call_url('POST', funcURL, payload)