* Trying 127.0.0.1...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 127.0.0.1 (127.0.0.1) port 8345 (#0)
> POST /rest/communities/cb69484b-1669-4832-b0aa-8acb902db531 HTTP/1.1
> User-Agent: curl/7.37.0
> Accept: */*
> Cookie: JSESSIONID=1041D8EFC72B7F930B6D3363406220FA
> Content-Type: application/json
> Content-Length: 526
>
} [data not shown]
* upload completely sent off: 526 out of 526 bytes
< HTTP/1.1 405
< Allow: DELETE,GET,OPTIONS,PUT
< Content-Type: text/html;charset=utf-8
< Content-Language: en
< Content-Length: 1090
< Date: Fri, 06 Dec 2019 08:45:03 GMT
<
{ [data not shown]
100 1616 100 1090 100 526 334k 161k --:--:-- --:--:-- --:--:-- 532k
* Connection #0 to host 127.0.0.1 left intact
<!doctype html><html lang="en"><head><title>HTTP Status 405 – Method Not Allowed</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;}
a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 405 – Method Not Allowed</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Method Not Allowed</p><p><b>Description</b> The method received in the request-line is known by the origin server but not supported by the target resource.</p><hr class="line" /><h3>Apache Tomcat/8.5.20</h3></body></html>
I allow Tomcat access only on localhost, and my script is on the same machine. I make the call with curl:
add_cmd = ['curl', '-v', '--cookie', self.sessionid, '--header', 'Content-Type: application/json', '-X', 'POST', item_link, '-d', json_str]
json_str = '''
{
"copyrightText": "",
"expand": [
"parentCommunityList",
"parentCommunity",
"items",
"license",
"logo",
"all"
],
"introductoryText": "Willkommen zu der neue Sammlung 1!",
"items": [],
"license": null,
"logo": null,
"name": "Neue Sammlung 1",
"shortDescription": "eine Sammlung via REST erzeugt",
"sidebarText": "",
"type": "collection"
}
'''