File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,3 +93,22 @@ The following example updates the content at the specified location.
9393 {
9494 "title": "My New Document Title"
9595 }
96+
97+
98+ Create content
99+ ==============
100+
101+ The following example creates content at the specified path with the given JSON body.
102+
103+ .. http :example :: curl plone-client
104+
105+ POST /Plone/folder HTTP/1.1
106+ Host: localhost:8080
107+ Content-Type: application/json
108+ Accept: application/json
109+ Authorization: Basic YWRtaW46YWRtaW4=
110+
111+ {
112+ "@type": "Document",
113+ "title": "My New Document"
114+ }
Original file line number Diff line number Diff line change @@ -68,6 +68,17 @@ def patch_content(request: HTTPRequest):
6868 cli.updateContent({ python_to_js_literal (payload )} );
6969"""
7070
71+ def post_content (request : HTTPRequest ):
72+ url = urlparse (request .url ())
73+ path = f'/{ url .path .split ("/" , 2 )[- 1 ]} '
74+ payload = {
75+ "path" : path ,
76+ "data" : request .data (),
77+ }
78+ return f"""\
79+ cli.createContent({ python_to_js_literal (payload )} );
80+ """
81+
7182
7283def build_plone_client_command (request : HTTPRequest ):
7384 url = urlparse (request .url ())
@@ -89,4 +100,6 @@ def build_plone_client_command(request: HTTPRequest):
89100 return output + get_content (request )
90101 elif request .command == "PATCH" :
91102 return output + patch_content (request )
103+ elif request .command == "POST" :
104+ return output + post_content (request )
92105 return output
You can’t perform that action at this time.
0 commit comments