如何传递项目';在Python中发送POST请求时,是否将值放入数组或列表?
这里是作为响应的2d81dc7e-fc34-49d4-b4a7-39a8179eaa55 现在我想将该witId用作以下json的输入:如何传递项目';在Python中发送POST请求时,是否将值放入数组或列表?,python,json,request,Python,Json,Request,这里是作为响应的2d81dc7e-fc34-49d4-b4a7-39a8179eaa55 现在我想将该witId用作以下json的输入: import requests import json import urllib2 data = '{"userId":"faraz@wittyparrot.com","password":"73-rRWk_"}' response = requests.post(url, data=data, headers= {"ContentType":"appli
import requests
import json
import urllib2
data = '{"userId":"faraz@wittyparrot.com","password":"73-rRWk_"}'
response = requests.post(url, data=data, headers=
{"ContentType":"application/json"})
dataa = json.loads(response.content)
a = dataa['accessToken']
print a
tiketId = a['tokenType'] + a['tokenValue']
print tiketId
wit = '{ "name": "wit along with the attachment","parentId": "6d140705-c178-4410-bac3-b15507a5415e", "content": "faraz khan wit", "desc": "This is testing of Authorization wit","note": "Hello auto wit"}'
response = requests.post(URLcreatewit, data=wit , headers={"Content-Type":"application/json","Authorization":tiketId} )
createwit = json.loads(response.content)
print createwit
Id = createwit['id']
WitId = Id
print WitId
所以在上一个json中,它似乎不接受witId的值,并给出400状态错误,我正试图做类似的事情,下面是我如何做的 假设RESTAPI使用Json对象进行响应
Sharewit = '{ "contentEntityIds":["'+WitId+'"],"userEmailIds": ["ediscovery111@gmail.com"],"permission":{"canComment": false,"canRead": true,"canEditFolderAndWits": false,"canFurtherShare": false,"canEditWits": false}, "inherit":true}'
response = requests.post(URLcreatewit, data= Sharewit , headers={"Content-Type":"application/json","Authorization":tiketId} )
print response.status_code
但是,如果响应是Json数组
通过数组循环并将ID附加到数组中
id = response.json()["id"]
此外,我还使用了Json对象来更改值。
而不是将其创建为Json字符串
item = []
for item in response.json():
ids.append(item["id")
我试着做类似的事情,下面是我是如何做到的 假设RESTAPI使用Json对象进行响应
Sharewit = '{ "contentEntityIds":["'+WitId+'"],"userEmailIds": ["ediscovery111@gmail.com"],"permission":{"canComment": false,"canRead": true,"canEditFolderAndWits": false,"canFurtherShare": false,"canEditWits": false}, "inherit":true}'
response = requests.post(URLcreatewit, data= Sharewit , headers={"Content-Type":"application/json","Authorization":tiketId} )
print response.status_code
但是,如果响应是Json数组
通过数组循环并将ID附加到数组中
id = response.json()["id"]
此外,我还使用了Json对象来更改值。
而不是将其创建为Json字符串
item = []
for item in response.json():
ids.append(item["id")
有人能帮帮我吗有人能帮帮我吗。。。。。。