我正在使用下面的常规代码使用上传 ID 删除单个上传,但是在尝试使用上传 ID 进行多次删除时出现错误。
/* The below function will delete upload files */
def delete_upload(server_url,each_upload_id,authentication){
def delete_upload_url = server_url + "/api/v1/uploads/" + upload_id
def response = httpRequest consoleLogResponseBody: true,
contentType: 'APPLICATION_JSON',
customHeaders: [[maskValue: false, name: 'id ', value: each_upload_id],
[maskValue: false, name: 'Authorization', value: authentication]],
httpMode: 'DELETE', ignoreSslErrors: true, responseHandle: 'NONE', url: delete_upload_url,
validResponseCodes: '100:599'
def result = readJSON text: """${response.content}"""
if(response.status == 202){
println ("Status code")
} else{
throw new Exception("Incorrect upload id! Please give the correct upload id.")
}
return result['message'].toString()
}
/* The below function will delete multiple uploads that exist in the server using upload id */
def delete_multiupload(server_url, upload_id, group_name, authentication){
String filepath = readfile "/data/Make/upload id.txt"
println (filepath)
def list = filepath.split(','). collect {it}
printIn(list)
list.each {
upload_id ->
printin "Calling the delete API for the upload id: $upload_id"
def delete_response = delete_upload (server_ur1,upload_id, group_name, authentication)
}
}
我低于错误,
The current scope already contains a variable of the name upload_id
@ line 34, column 14.
list.each {
^
1 error
delete_upload 函数工作正常。我正在尝试添加另一个函数 delete_multiupload 以删除多个上传。
要求:我需要在 delete_multiupload 中使用/调用 delete_upload 函数,以便它可以删除多个上传。
有什么建议吗?