how to upload file on Box Content API using httpclient?
回答済みBecause the Java Box SDK does not work for my environment, I'm making REST calls and when I Submit the following request:
HttpPost httppost = new HttpPost(baseURl + "/files/content"); HttpEntity reqEntity = MultipartEntityBuilder.create() .addPart("attributes", new StringBody("{\"name\":\"C7L1HLeXUAEHtgm.jpeg\",\"parent\":{\"id\":\"0\"}}", ContentType.APPLICATION_JSON)) .addPart("file", new FileBody(file, ContentType.create("image/jpg"))) .build(); httppost.setEntity(reqEntity); httppost.setHeader("Authorization", "Bearer " + accessToken);
Because the Java Box SDK does not work for my environment, I'm making REST calls and when I Submit the following request:
HttpPost httppost = new HttpPost(baseURl + "/files/content"); HttpEntity reqEntity = MultipartEntityBuilder.create() .addPart("attributes", new StringBody("{\"name\":\"C7L1HLeXUAEHtgm.jpeg\",\"parent\":{\"id\":\"0\"}}", ContentType.APPLICATION_JSON)) .addPart("file", new FileBody(file, ContentType.create("image/jpg"))) .build();httppost.setEntity(reqEntity);httppost.setHeader("Authorization", "Bearer " + accessToken);
I get the following response: HTTP/1.1 404 Not Found
Box
I don't see what I'm missing here. I've been following the instructions from https://developer.box.com/v2.0/reference#upload-a-file.
PS: I already know how to navigate through folders and create new ones.
サインインしてコメントを残してください。
コメント
6件のコメント