I’m currently able to use a GET/inquire request to the REST API to retrieve a contentlet.
Once I have it then is it possible to change a value in the contentlet, and then do a POST to update the newly changed contentlet?
The value(s) I want to try to change are publish/unpublish/archive/unarchive/delete flags or values, that would mimic the manual process of doing an unpublish, archive, and then delete of entries manually.
Or instead of trying to do the delete process programmatically(especially if it’s not possible currently), what would be the best way to update an entry to indicate that it needs to be deleted in the future?
Thanks.
Henry
--
http://dotcms.com - Open Source Java Content Management
---
You received this message because you are subscribed to the Google Groups "dotCMS User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotcms+un...@googlegroups.com.
To post to this group, send email to dot...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377737163D54AE27CAA5BF15AD190%40CY4PR0501MB3777.namprd05.prod.outlook.com.
For more options, visit https://groups.google.com/d/optout.
Chris,
I’ve looked in the documentation and the only example I saw was one that looked like it executed just one subaction of a particular workflow like this:
PUT /api/content/Assign%20for%20Review/1/wfActionComments/Hey%2C%20take%20a%20look/wfActionAssign/dotCMS.org.7575
But it doesn’t to explain all of the parts of the URI shown, unless there are more detailed examples of calling a workflow through the REST API.
So I have questions about the above URI.
1.) Is the actual sub-action to be executed this part of the URI: /Assign%20for%20Review/
2.) ‘wfActionComments’ indicates that what follows it in the next part of the URI ( /Hey%2C%20take%20a%20look/ ) is a comment right? If so is it mandatory for comments to always be declared and formatted this way and in this same position?
3.) So is the /wfActionAssign/ part of the URI the name of the actual workflow/workflow scheme?
4.) I’m Assuming that when a workflow scheme is created, then that workflow scheme must also be associated with the content type to be operated on, before it can be called via the REST API. Correct?
5.) And finally in the example above is the last part of the URI above ‘dotCMS.org.7575’ always a content identifier of the contentlet to be operated on, by the workflow?
Let me know when you can.
Thanks.
Henry
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgVp6RxJUWproVrCmWOyQuAbrTuKBi6oSV9YAe-9X7jw_g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377752526746F751320258D2AD190%40CY4PR0501MB3777.namprd05.prod.outlook.com.
Chris,
I asked question 5 because if I don’t supply an identifier, for the content to be operated on then how will the workflow know which contentlet it is to apply itself?
And are the “wfActionComments” and “wfActionAssign” strings like hard-coded keys of those key/value pairs?
Let me know when you can and thanks for the explanations thus far.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgXONwhioggwofQwoR0%2BoVagS3_xqpyZZj7uKDQB4tPTPw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377754B3768C33A152FE490FAD1E0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
Chris,
So if I understand you right then the comments key/value pair and the id key/value pair would be inside a json object then in the request body right?
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgUwvhm%2BnXAN_YHr%3Dst7t5_5agC_MqEMG6jt_%2B9sm%3DNFgA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377704E170D8955F6502F0FEAD1E0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
I believe that last part is the user id to assign the workflow to. “dotCMS.org.7575”
Nathan I. Keiter
|
Lead Network Applications Programmer
|
Benefits Advisory Council Member
|
I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB377752526746F751320258D2AD190%40CY4PR0501MB3777.namprd05.prod.outlook.com.
Nathan,
In my particular situation I’m trying to delete a particular item contentlet from its structure, by way of the REST API.
So I was hoping to pass the contentlet id value to my workflow using the “wfActionAssign” key, so the workflow would only operate on that single piece of content.
Is that the way to do it then?
And should I include it in the request as part of the URL, or as a key/value pair in a json object?
Henry
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/1542fb25a08042b6bc1b6c293a1b9b7d%40exch13b.ms.gettysburg.edu.
I believe you are correct.
It looks like workflow stuff in URL.
https://dotcms.com/docs/latest/rest-api-end-points#ContentResource
Then object in payload.
https://dotcms.com/docs/latest/save-content-using-the-rest-api#json
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB37777EC73B2BEADAC3F06812AD1E0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
So my workflow scheme that I’m trying to use and call the action from is named “REST API Test”.
It has two workflow steps defined within it.
The first step name is “Lock” and contains an action named “REST API Lock Employee” which has only one sub-action of “Lock content”.
The second step is “Delete” and contains an action named “REST API Delete Employee” which has only one sub-action of “Delete content”.
I think I read in the documentation that a “Delete content” sub-action will automatically do an Unpublish, an Archive, and a Delete all in one call, so that’s what I’m hoping to do when calling my “REST API Delete Employee” action and here’s what my latest request looks like(minus the domain):
/api/content/REST%20API%20Delete%20Employee/1/wfActionComments/Deleted%20Employee%20Contentlet%20ID%20of%20%289554f6e0-8dc4-4d36-a033-f9a09ab2ddf0%29%2E/wfActionAssign/9554f6e0-8dc4-4d36-a033-f9a09
ab2ddf0
using the suggested format with both comments and the identifier showing as part of the URL. I’m also using the PUT method with this request.
I’m also using only two headers, with this request. One for my authorization header and an “Accept” header for “text/plain” which seems to be common.
So far when I try to call the delete action mentioned above I’ve gotten this web exception:
WARNING: Delete-Employee-PSItemString=HTTP Status 400 - Bad Request
type Status report
message Bad Request
description The request sent by the client was syntactically incorrect.
Apache Tomcat/8.0.18
WARNING: Delete-Employee-InvocationInfo=System.Management.Automation.InvocationInfo
WARNING: Delete-Employee-ExceptionMessage=The remote server returned an error: (400) Bad Request.
WARNING: Delete-Employee-InnerException=
WARNING: Delete-Employee-ExceptionStacktrace= at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
WARNING: Delete-Employee-ScriptStackTrace=at Delete-Employee, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 337
at ReadAddUpdate-File, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 957
at <ScriptBlock>, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 1033
WARNING: ReadAddUpdate-File-PSItemString=The remote server returned an error: (400) Bad Request.
WARNING: ReadAddUpdate-File-InvocationInfo=System.Management.Automation.InvocationInfo
WARNING: ReadAddUpdate-File-ExceptionMessage=The remote server returned an error: (400) Bad Request.
WARNING: ReadAddUpdate-File-InnerException=
WARNING: ReadAddUpdate-File-ExceptionStacktrace= at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
WARNING: ReadAddUpdate-File-ScriptStackTrace=at Delete-Employee, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 416
at ReadAddUpdate-File, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 957
at <ScriptBlock>, C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1: line 1033
The remote server returned an error: (400) Bad Request.
At C:\Users\hversemann\CAMPUS_DIRECTORY_AUTO_UPDATE_PROJECT\CAMPUS_DIRECTORY_UPDATE_AUTOMATION\Staging_PartTimeEmployeeUpdates_UsingWebRequest4_12212017.ps1:1000 char:9
+ throw $_.Exception
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], WebException
+ FullyQualifiedErrorId : The remote server returned an error: (400) Bad Request.
So I’m trying to figure out how to change my request, to be more syntactically correct.
Any thoughts on some more things or format variations that I can try?
Thanks for the help.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/cfb1ff94bc444531a0647e2feb7d85dd%40exch13b.ms.gettysburg.edu.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CY4PR0501MB37779B8C637C2F9494F3225CAD1E0%40CY4PR0501MB3777.namprd05.prod.outlook.com.
That’s pretty cool Chris. I didn’t see anything about delete in the documentation.
Nathan I. Keiter
|
Lead Network Applications Programmer
|
Benefits Advisory Council Member
|
I.D.E.A Council Member
Gettysburg College | Information Technology | DataSystems
Campus Box 2453 | 300 North Washington Street | Gettysburg, PA 17325
Phone: 717.337.6993
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgWxXE_pAU%3D8QgnhCZWFj025HcGM4WWwD%3DgoQeZcKg9J7w%40mail.gmail.com.
Chris,
So for a delete action what else besides maybe language id would be required for a delete?
The fields marked in red in the backend when I open up an entry for the structure in question, or something more than those?
Thanks for the help.
Henry
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgWxXE_pAU%3D8QgnhCZWFj025HcGM4WWwD%3DgoQeZcKg9J7w%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/91b8d27769484132887e59974efe28cf%40exch13b.ms.gettysburg.edu.
OK thanks.
I’ll try it and see what happens.
To view this discussion on the web visit https://groups.google.com/d/msgid/dotcms/CAMAbHgU_FCbdMaFNbJE-kVde%2BoWSC%3DnsqTvPe53PPWh6G_3LQw%40mail.gmail.com.