How do you update/change Parent ID of an item in ShareFile using Java APIs? Or how do you move an item in ShareFile using Java APIs?

  • 1
  • Question
  • Updated 1 year ago
Here's my code

public static void updateParent(OAuth2Token token,
String id, String parentId) 
throws IOException, ParseException
URL url = new URL(String.format("https://%s/sf/v3/Items(%s)";, ShareFileV3SampleSE.getHostname(token), id));
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.addRequestProperty("Content-Type", "application/json");
ShareFileV3SampleSE.addAuthorizationHeader(connection, token);
// HttpUrlConnection does not support the PATCH method by default
connection.addRequestProperty("X-HTTP-Method-Override", "PATCH");
System.out.println(connection.getRequestMethod() + " " + connection.getURL());

Map<String, Object> folder = new HashMap<String, Object>();
folder.put("parentid", parentId);

Gson gson = new Gson();
String body = gson.toJson(folder);


BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {

System.out.println(connection.getResponseCode() + " " + connection.getResponseMessage());
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("Updated folder");
Photo of Eiks Lector

Eiks Lector

  • 1 Post
  • 0 Reply Likes

Posted 1 year ago

  • 1
Photo of Dale Smith

Dale Smith, Software Engineer

  • 216 Posts
  • 33 Reply Likes
Hi Eiks,

While we don't directly expose the Move API currently, it is under consideration to move it from internal to public. In the mean time, you can always perform a Copy operation for the file to the destination parent folder, and then delete the file from the source folder. You can take a look at the Copy Item section of

Let us know if that helps,