1

我们正在尝试通过 JAVA 按照以下过程将文档上传到消耗 REST 的任务

Uploads and Documents API 2.0 允许用户通过以下 API URL 上传文档:

POST /attask/api/upload

API 期望内容类型为 multipart/form-data。文件的参数名称必须是uploadFile。服务器将返回以下 JSON 数据:

{
"handle": "4c7c08fa0000002ff924e298ee148df4"
}

然后可以在创建 Workfront 文档时使用该句柄。要创建 Workfront 文档,您将发布到以下 URL:

        POST /attask/api/document?updates={
             name: aFileName,
             handle: abc...123, (handle from the file upload)
             docObjCode: PROJ, (or TASK, OPTASK, etc)
             objID: abc...123,
             currentVersion:{version:v1.0,fileName:aFileName}
           }

下面是我尝试使用rest api进行上传的java示例代码

 Map<String, Object> map = new HashMap<String, Object>();
 map.put("Content-Type", "multipart/form-data");
 map.put("name", new File("test.txt"));
 JSONObject handle = client.post("upload", map);
 System.out.println("Handle" + handle.getString("handle") );

我们得到 filenotfound 异常。如果有人通过 JAVA 将文件上传到项目中的任务。你能分享一些见解吗?提前致谢

4

0 回答 0