baptiste Posted April 25, 2022 Report Share Posted April 25, 2022 Hi, When using Plastic SCM GUI, a item removed locally (a deleted file) appears in the "Pending Changes" section and this change can be checkin. I cannot figure out how to to replicate this using the REST API, i.e I would like to checkin a file deletion. I tried setting the `paths` parameter to the path of the deleted file or of the directory where the deleted file was located. url = __api_url + f"/wkspaces/myworkspace/checkin" params = { "paths": [ "wkpath/to/file" # also tried "wkpath/to/file_dir" ], "comment": "Deleting a file", "recurse": True, } res = requests.post( url, headers={ "Content-type": "application/json", "Accept": "application/json", }, data=json.dumps(params), ) print(res.json()) # will print: {'totalSize': 0, 'transferredSize': 0, 'status': 'Checkin operation starting...'} And the response returned by a GET at "api/v1/wkspaces/myworkspace/checkin" is: {"status":"Failed", "message":"There are no changes in the workspace c:\\Users\\Baptiste\\wkspaces\\myworkspace"} What am I missing? How do you submit a file deletion when using the REST API? Thank you! Link to comment Share on other sites More sharing options...
Rafael Posted May 4, 2022 Report Share Posted May 4, 2022 Hi, Sorry for the delayed response. Leaving the path parameter empty while you have a pending deleted file should checkin the deletion. Have you tried that? https://www.plasticscm.com/documentation/restapi/plastic-scm-version-control-rest-api-guide#Checkin Let me know if I understood your question correctly. Regards, RafaelUnity Plastic SCM SupportVirtualize your Workspace. Make it dynamic. Link to comment Share on other sites More sharing options...
baptiste Posted May 6, 2022 Author Report Share Posted May 6, 2022 Hi Rafael, I tried leaving the `paths` parameter empty, either by passing an empty list: params = { "paths": [], "comment": "Deleting a file", "recurse": True, } or by omitting the parameter: params = { "comment": "Deleting a file", "recurse": True, } In both cases, I tried with recurse set to `True` or `False`. The returned response is always: {'totalSize': 0, 'transferredSize': 0, 'status': 'Checkin operation starting...'} The item still appears in the "Pending Changes " as "Removed locally". Cheers, Baptiste Link to comment Share on other sites More sharing options...
ollieblanks Posted May 11, 2022 Report Share Posted May 11, 2022 Hi @baptiste, To check in the deletion of a file removed locally, you first need to bring it under Plastic control by checking it out. Hope this helps! Link to comment Share on other sites More sharing options...
baptiste Posted May 13, 2022 Author Report Share Posted May 13, 2022 Hi @ollieblanks, Thank your answer. Does it mean it's not possible to check in an item deletion if the file has already been removed from the workspace? I tried your suggestion, but I still can't' check in the deletion. Here's what I've been trying to do: I have a workspace named "test_decentralized", with a "cube.glb" file at the root of this workspace. I want to be able to delete this file and check in this deletion. wkname = "test_decentralized" path = "cube.glb" # Its actual filepath on my system is "C:\\Users\\Baptiste\\wkspaces\\test_decentralized\\cube.glb" # Checkout the file url = __api_url + f"/wkspaces/{wkname}/content/{path}" res = requests.put(url) print(f"req.status_code = {res.status_code}") if res.status_code != 200: raise print(res.json()) # -> seems to work, I get "{'affectedPaths': ['c:\\Users\\Baptiste\\wkspaces\\test_decentralized\\cube.glb']}" # Locally remove the file os.remove("C:\\Users\\Baptiste\\wkspaces\\test_decentralized\\cube.glb") # Try to checkin this deletion url = __api_url + "wkspaces/test_decentralized/checkin" params = { "paths": ["cube.glb"], # I also tried passing an empty list this empty "comment": "Deleting a file", "recurse": True, } res = requests.post( url, headers={ "Content-type": "application/json", "Accept": "application/json", }, data=json.dumps(params), ) print(res.json()) # -> {'totalSize': 0, 'transferredSize': 0, 'status': 'Checkin operation starting...'} res = requests.get(__api_url + f"wkspaces/{wkname}/checkin") print(res.json()) # -> {'status': 'Failed', 'message': 'The item c:\\Users\\Baptiste\\wkspaces\\test_decentralized\\cube.glb does not exist in the workspace.'} The cube.glb file is liested in Plastic GUI in the "Pending Changes" tab, as a deleted item with a status "Removed locally". Cheers, Baptiste Link to comment Share on other sites More sharing options...
ollieblanks Posted May 25, 2022 Report Share Posted May 25, 2022 Hi @baptiste, You are right, this does not work. I believe the problem here is that the API is missing a method for a "controlled delete". I will share this with the team and keep you updated. Link to comment Share on other sites More sharing options...
ollieblanks Posted May 25, 2022 Report Share Posted May 25, 2022 It turns out that a "controlled delete" method does exist, it is just not documented. Can you please try the below? Link to comment Share on other sites More sharing options...
baptiste Posted May 27, 2022 Author Report Share Posted May 27, 2022 Hi @ollieblanks, Thank you, it works! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now