我使用python请求库进行以下调用:
response = requests.post(
'https://blockchain-starter.eu-gb.bluemix.net/api/v1/networks/<network id>/chaincode/install',
headers={
'accept': 'application/json',
'content-type': 'multipart/form-data',
'authorization': 'Basic ' + b64encode(credential['key'] + ":" + credential['secret'])
},
data={
'chaincode_id': chaincode_id,
'chaincode_version': new_version,
'chaincode_type': chaincode_type,
'files': open('chaincode.zip', 'rb')
}
)
然而,当我进行调用时,我得到一个500内部服务器错误(API是this,特别是Peers / Install Chaincode)。鉴于我之前对GET端点之一的调用工作正常,我假设我的请求有问题,有人能帮忙吗
更新:
解决方案是删除content-type
头并将文件上载移到它自己的files
参数中:
response = requests.post(
https://blockchain-starter.eu-gb.bluemix.net/api/v1/networks/<network id>/chaincode/install,
headers={
'accept': 'application/json',
'authorization': 'Basic ' + b64encode(credential['key'] + ":" + credential['secret'])
},
data={
'chaincode_id': chaincode_id,
'chaincode_version': new_version,
'chaincode_type': chaincode_language
},
files={
'file': open('chaincode_id.zip', 'rb')
}
)
正如提问者所承认的那样,ralf htp的回答似乎解决了他们的问题
相关问题 更多 >
编程相关推荐