Hi,
I am trying to batch create communities in DSpace from command line on a 
Redhat server. The server is a RHEL6 and the installation is a vanilla 
DSpace 4.2.

I am able to get information about existing Communitites in my DSpace 
installation with a curl command like this:
curl -i -H "user:usern...@something.uib.no" -H "pass:XXXXXX" -H 
"Content-Type: text/xml" -X GET "http://localhost:8080/rest/communities";

The result is given out:
> [{"id":1,"name":"IT 
> avdelingen","handle":"123456789/1","type":"community","link":"/rest/communities/1","expand":["parentCommunity","collections","subCommunities","log
> o","all"],"logo":null,"parentCommunity":null,"copyrightText":"","introductoryText":"felles","shortDescription":"ITA","sidebarText":"","countItems":1,"collections":[],
> "subcommunities":[]}]

But, when I try to POST data, I can understand how it should be done.
I am trying to do something like this:

> curl -X POST -i -H "user:usern...@something.uib.no" -H "pass:XXXXXXX" 
> -H "Content-Type: application/json" -d "{'communityId':'1','name':'A 
> test community','shortDescription':'Community created with JSON'}" 
> "http://localhost:8080/rest/communities";

which might not be the correct way. I have tried others also. The answer 
from Tomcat is:

> HTTP/1.1 405 Method Not Allowed
> Server: Apache-Coyote/1.1
> Allow: GET,OPTIONS,HEAD
> Content-Type: text/html;charset=utf-8
> Content-Length: 1034
> Date: Thu, 29 Jan 2015 13:13:12 GMT
>
> <html><head><title>Apache Tomcat/6.0.24 - Error 
> report</title><style><!--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;}HR {color : 
> #525D76;}--></style> </head><body><h1>HTTP Status 405 - Method Not 
> Allowed</h1><HR size="1" noshade="noshade"><p><b>type</b> Status 
> report</p><p><b>message</b> <u>Method Not 
> Allowed</u></p><p><b>description</b> <u>The specified HTTP method is 
> not allowed for the requested resource (Method Not 
> Allowed).</u></p><HR size="1" noshade="noshade"><h3>Apache 
> Tomcat/6.0.24</h3></body></html>

The documentation that I try to follow (and understand) is this one:
* https://jspace.atlassian.net/wiki/display/DSPACEAPI/POST_communities

Can someone please point me in the right direction in how to be able to 
POST to DSpace API to be able to create communities (and other elements 
later on)?

My goal is to be able to create from another data source maybe a couple 
of hundreds or thousands communities in 1 DSpace installation, and I can 
not do this by the xmlui web interface, because it would take way to 
much time.

Thank you very much,

best regards,

Helge
University of Bergen
Norway


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
DSpace-tech mailing list
DSpace-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dspace-tech
List Etiquette: https://wiki.duraspace.org/display/DSPACE/Mailing+List+Etiquette

Reply via email to