requests.post() のデータ フィールドに変数を渡そうとしていますが、引き続きエラーが発生します。
Error Response: {'error': {'message': 'Exception while reading request',
'detail': 'Cannod decode: java.io.StringReader@1659711'}, 'status': 'failure'}
これが私のコードです
#Fill array from CSV
temp=[]
for row in csv.iterrows():
index, data = row
temp.append(data.tolist())
#Create new asset for all assets in CSV
for index, row in enumerate(temp):
make = temp[index][0]
serial = str(temp[index][1])
date = str(temp[index][2])
response = requests.post(url, auth=(user, pwd), headers=headers,
data='{"asset_tag":"test1", "assigned_to":"test2",
"company":"test3", "serial_number":serial}')
私は元々、CSVから直接フィードしようとしました
str(temp[index][1])
これはうまくいかなかったので、変数に代入str(temp[index][1])
してからそのように変数を渡そうとserial
しましたが、それも同じエラーになります。
正しい方向へのポイントは素晴らしいでしょう、ありがとう!