Hi Paul,
It looks (to me) like you are POSTing to the wrong endpoint (based on the docs
you linked to)
Your POST looks like this:
POST /rest/communities/cb69484b-1669-4832-b0aa-8acb902db531
But, the correct POST to create a collection is:
POST /rest/communities/cb69484b-1669-4832-b0aa-8acb902db531/collections
So, the error you are seeing is correct. You cannot POST to just the
/communities/{uuid} endpoint...that endpoint only accepts GET (to get info
about that Community), DELETE (to delete that community) and PUT (to update
that community). If you want to add a collection, you have to POST to the
/collections subresource for that community.
Hopefully that helps!
Tim
________________________________
From: [email protected] <[email protected]> on behalf of
Paul Warner <[email protected]>
Sent: Friday, December 6, 2019 3:07 AM
To: DSpace Technical Support <[email protected]>
Subject: [dspace-tech] DSpace 6.3 REST 405 Error when posting new collection
I am attempting to add a collection, and am getting a 405 Method Not Allowed
error. DSpace 6.3. Thanks in advance for any suggestions! --Paul
In the output below, note the line: < Allow: DELETE,GET,OPTIONS,PUT
POST is not on the list! Why?
According to the documentation, creation of a collection uses a POST request.
https://wiki.lyrasis.org/display/DSDOC6x/REST+API#RESTAPI-Communities
Here is the server output:
* 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
> Host: 127.0.0.1:8345
> 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>
In anticipation of possible questions, here is the way I make the REST call:
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]
item_link = 'using
http://127.0.0.1/rest/communities/cb69484b-1669-4832-b0aa-8acb902db531'
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"
}
'''
Thanks,
Paul
--
All messages to this mailing list should adhere to the DuraSpace Code of
Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/dspace-tech/76c0d141-87d1-4ae4-aeb1-0d1aa0f2c75d%40googlegroups.com<https://groups.google.com/d/msgid/dspace-tech/76c0d141-87d1-4ae4-aeb1-0d1aa0f2c75d%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
All messages to this mailing list should adhere to the DuraSpace Code of
Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups
"DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/dspace-tech/DM5PR2201MB1148CF138939897976982829ED5F0%40DM5PR2201MB1148.namprd22.prod.outlook.com.