cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

invalid_revision error while restoring file version through api

invalid_revision error while restoring file version through api

AmanSingh
Explorer | Level 3

 

I am trying to restore file to an older versiScreenshot 2021-11-25 101146.jpgon through API but it throws the error as shown in the picture.
What can be best solution to use through API ?

Hope for the quick reply.

Thanks & Regards
Aman

9 Replies 9

Greg-DB
Dropbox Staff

The /2/files/restore endpoint is the right way to restore a previous version of a file. An 'invalid_revision' error like that should indicate that the value you supplied in the "rev" parameter isn't usable though, e.g., it's not an actual revision value, or it refers to a version that cannot be restored (e.g., because it doesn't exist anymore).

 

If something's not working as expected/documented, I'll be happy to look into it, but I'd need some more information. In that case, reply with:

  • the name and version number of the SDK/library you are using, if any
  • the steps to reproduce the issue, including relevant code snippet(s), but don't include any access or refresh token(s)
  • the full text of any error or unexpected output

AmanSingh
Explorer | Level 3

Hi,
Thanks for the response.

Actually I am trying to restore a deleted file through this API.
But its showing this "invalid_revision" error.
Also the file I am trying to restore is deleted within 30 days. (2-3 days before)

What can be the reason, anything to help here?

I am using Dropbox Java SDK v4.0.1
Error message I am getting - Exception in 2/files/restore: "invalid_revision"

Здравко
Legendary | Level 20

@AmanSingh wrote:

...
Error message I am getting - Exception in 2/files/restore: "invalid_revision"


Hi @AmanSingh,

How and where did you get the revision from, that gets refused here as an invalid? 🤔 Can you describe exact steps or, as @Greg-DB has mentioned above, share some code snippet reproducing the issue?

Greg-DB
Dropbox Staff

@AmanSingh Yes, as Здравко mentioned, please share the relevant code. It would be useful if you show both where/how you're get the revision value, as well as where/how you're using it. It may also be helpful for troubleshooting purposes to print out the value itself.

AmanSingh
Explorer | Level 3
Hi,
Thanks for the response.

Using Dropbox Java SDK v4.0.1 for development. I am trying to restore deleted files using -

files().restore(path, rev)
But its throwing an error "invalid_revision".
I am getting path from metadata for deleted file in listFolder() with includeDeleted = true.
And I am getting rev from listRevisions() for the file. Getting the latest revision from that list.

Is this API correct to do this task or is there anything to help ?

Thanks
Aman

Greg-DB
Dropbox Staff

@AmanSingh The listFolder/listFolderContinue methods are the right way to list the contents of a folder, the listRevisions method is the right way to list the versions of a file, and the restore method is the right way to restore a deleted file. I just gave these a try myself and they are working properly for me. If it's not working for you, please share the rest of the relevant code and output so we can take a look at what's not working for you specifically. Thanks!

AmanSingh
Explorer | Level 3

Hi,

Thanks for the information.

So, that's my sample code - 

String path = "/testaman6.dwg";
List<FileMetadata> revisions = new AWSXRayDbxClientV2(api, xRay).files().listRevisions(path).getEntries();
String rev = revisions.get(0).getRev();
new AWSXRayDbxClientV2(api, xRay).files().restore(path, rev);

Inputs for restore function - 
path - /testaman6.dwg

rev - 015d183052af6b300000002296c5930

Error I am getting - Exception in 2/files/restore: "invalid_revision"

Greg-DB
Dropbox Staff

@AmanSingh Thanks! That code itself looks fine, so it sounds like there's something specific to your account/files relevant here. Could you please open an API ticket and share the entire output you get from 'new AWSXRayDbxClientV2(api, xRay).files().listRevisions(path)' itself? That should help us investigate internally. Thanks in advance and apologies for the bother.

AmanSingh
Explorer | Level 3

Thanks for the information.

I have raised a ticket for this - https://www.dropbox.com/support/ticket/15701428

Hope for a quick response.

Thanks

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    AmanSingh Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?