以下是post方法。我需要将文件附加到jira问题。为此,我创建了post API,它调用jira rest API来添加附件。当我运行代码时它在我的本地工作,但是当我在本地机器上的IIS服务器中托管时,JSON对象中的文件路径不起作用。
connect()
json对象在
之下 [HttpPost]
public IActionResult Post([FromBody]AttachmentFiles FilePaths)
{
string restUrl = String.Format("{0}rest/api/2/issue/{1}/attachments", FilePaths.Url, FilePaths.issueKey);
var filesToUpload = new List<FileInfo>();
foreach (var filePath in FilePaths.filePaths)
{
if (!System.IO.File.Exists(filePath))
{
var js = @"{""errormessage"":""File doesn't exist""}";
object actionPlanModel = JsonConvert.DeserializeObject(js);
return Json(actionPlanModel);
}
var file = new FileInfo(filePath);
filesToUpload.Add(file);
}
if (filesToUpload.Count <= 0)
{
var js = @"{""errormessage"":""No file to Upload""}";
object actionPlanModel = JsonConvert.DeserializeObject(js);
return Json(actionPlanModel);
}
var result= SubmitFile(restUrl, FilePaths, filesToUpload);
return Json(result);
}
任何人都可以帮我这个吗?