[GeoNetwork-users] help to use the rest API of geonetwork

Hello all,

as i do not know yet how to use the geonetwork API, i use the owslib library in order to send data to geonetwork. but metadata are not public, and i need to change the acces permissions with the admin console https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board

it is also possible to change acces permissions with the following PostgreSQL queries, observed in the postgresql logs :

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '5'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '0'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '1'

my questions :

- is it possible to do that with the REST API of geonetwork ?
- it is possible to send data to geonetwork with its API ?

at the moment, i did not succeed when i tried to use this API. it is here to find the documentation, for example here :
https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw

but i only get HTML errors with the HttpRequester plugin of Mozilla :
GET http://localhost:8080/geonetwork/srv/api/0.1/me -> error 406
GET http://localhost:8080/geonetwork/srv/api/0.1/search/ping -> error 406

any help would be appreciated.

Ernest.

--
Ernest CHIARELLO - Ernest.Chiarello@anonymised.com
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66 Mob : 07 82 99 11 08

oups, it seems that the string SRV should not be used !

localhost:8080/geonetwork/srv/cswis correct :

>>> urllib2.urlopen("http://localhost:8080/geonetwork/srv/csw"\).read()
'<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login" lang="eng" id="ng-app">\n <head>\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <title>My GeoNetwork catalogue - My organization</title>\n <meta charset="utf-8">\n <meta name="viewport" content="initial-scale=1.0, user-scalable=no">\n <meta name="apple-mobile-web-app-capable" content="yes">\n <meta name="description" content="">\n <meta name="keywords" content="">\n <link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../images/logos/favicon.png">\n <link href="rss.search?sortBy=changeDate" rel="alternate" type="application/rss+xml" title="My GeoNetwork catalogue - My organization">\n <link href="portal.opensearch" rel="search" type="application/opensearchdescription+xml" title="My GeoNetwork catalogue - My organization">\n <link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" media="screen">\n </head>\n <body data-ng-controller="GnCatController">\n <div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar" data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n <div data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n <div ng-include="\'../../catalog/templates/info.html\'"></div><script src="/geonetwork/static/lib.js"></script><script src="/geonetwork/static/gn_login.js"></script><noscript>\n <div class="alert" data-ng-hide=""><strong></strong> \n </div>\n </noscript>\n </body>\n</html>'

but localhost:8080/geonetwork/srv/api/0.1/usersis not correct.

>>> urllib2.urlopen("http://localhost:8080/geonetwork/srv/api/0.1/users&quot;\).read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 406: Not Acceptable

remove "srv", and it works fine !

>>> urllib2.urlopen("http://localhost:8080/geonetwork/api/0.1/users&quot;\).read()
'<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login" lang="eng" id="ng-app">\n <head>\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n <title>My GeoNetwork catalogue - My organization</title>\n <meta charset="utf-8">\n <meta name="viewport" content="initial-scale=1.0, user-scalable=no">\n <meta name="apple-mobile-web-app-capable" content="yes">\n <meta name="description" content="">\n <meta name="keywords" content="">\n <link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../images/logos/favicon.png">\n <link href="rss.search?sortBy=changeDate" rel="alternate" type="application/rss+xml" title="My GeoNetwork catalogue - My organization">\n <link href="portal.opensearch" rel="search" type="application/opensearchdescription+xml" title="My GeoNetwork catalogue - My organization">\n <link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="screen">\n <link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" media="screen">\n </head>\n <body data-ng-controller="GnCatController">\n <div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar" data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n <div data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n <div ng-include="\'../../catalog/templates/info.html\'"></div><script src="/geonetwork/static/lib.js"></script><script src="/geonetwork/static/gn_login.js"></script><noscript>\n <div class="alert" data-ng-hide=""><strong></strong> \n </div>\n </noscript>\n </body>\n</html>'

sorry for the noise...

Ernest.

Le 02/10/2017 à 10:53, Chiarello Ernest a écrit :

Hello all,

as i do not know yet how to use the geonetwork API, i use the owslib library in order to send data to geonetwork. but metadata are not public, and i need to change the acces permissions with the admin console https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board

it is also possible to change acces permissions with the following PostgreSQL queries, observed in the postgresql logs :

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '5'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '0'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId, metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '1'

my questions :

- is it possible to do that with the REST API of geonetwork ?
- it is possible to send data to geonetwork with its API ?

at the moment, i did not succeed when i tried to use this API. it is here to find the documentation, for example here :
https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw

but i only get HTML errors with the HttpRequester plugin of Mozilla :
GET http://localhost:8080/geonetwork/srv/api/0.1/me -> error 406
GET http://localhost:8080/geonetwork/srv/api/0.1/search/ping -> error 406

any help would be appreciated.

Ernest.

--
Ernest CHIARELLO - Ernest.Chiarello@anonymised.com
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66 Mob : 07 82 99 11 08

Hi

In current version there's a mix of "old" services using Jeeves engine (the
ones using /srv/) and new API services that use /api/.

Old services are mark in the source code as @Deprecated and will be removed
in next versions. Afaik in 3.4.x (next version) will be still available,
but when released the following one (3.6 or whatever name it gets) most
probably will be removed.

The plan is to migrate all services to the new API.

You can check/test current services in
http://localhost:8080/geonetwork/doc/api/

Regards,
Jose García

On Mon, Oct 2, 2017 at 12:12 PM, Chiarello Ernest <
Ernest.Chiarello@anonymised.com> wrote:

oups, it seems that the string SRV should not be used !

localhost:8080/geonetwork/srv/cswis correct :

>>> urllib2.urlopen("http://localhost:8080/geonetwork/srv/csw&quot;\).read()
'<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login" lang="eng"
id="ng-app">\n <head>\n <meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">\n <title>My GeoNetwork catalogue -
My organization</title>\n <meta charset="utf-8">\n <meta
name="viewport" content="initial-scale=1.0, user-scalable=no">\n <meta
name="apple-mobile-web-app-capable" content="yes">\n <meta
name="description" content="">\n <meta name="keywords"
content="">\n <link rel="icon" sizes="16x16 32x32 48x48"
type="image/png" href="../../images/logos/favicon.png">\n <link
href="rss.search?sortBy=changeDate" rel="alternate"
type="application/rss+xml" title="My GeoNetwork catalogue - My
organization">\n <link href="portal.opensearch" rel="search"
type="application/opensearchdescription+xml" title="My GeoNetwork
catalogue - My organization">\n <link href="/geonetwork/static/gn_login_default.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/bootstrap-table.min.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/ng-skos.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/srv_custom_style.css"
rel="stylesheet" media="screen">\n </head>\n <body
data-ng-controller="GnCatController">\n <div class="navbar
navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar"
data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
<div data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
<div ng-include="\'../../catalog/templates/info.html\'"></div><script
src="/geonetwork/static/lib.js"></script><script
src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
class="alert" data-ng-hide=""><strong></strong> \n </div>\n
</noscript>\n </body>\n</html>'

but localhost:8080/geonetwork/srv/api/0.1/usersis not correct.

>>> urllib2.urlopen("http://localhost:8080/geonetwork/srv/api/0.1/users
").read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 406: Not Acceptable

remove "srv", and it works fine !

>>> urllib2.urlopen("http://localhost:8080/geonetwork/api/0.1/users
").read()
'<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login" lang="eng"
id="ng-app">\n <head>\n <meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">\n <title>My GeoNetwork catalogue -
My organization</title>\n <meta charset="utf-8">\n <meta
name="viewport" content="initial-scale=1.0, user-scalable=no">\n <meta
name="apple-mobile-web-app-capable" content="yes">\n <meta
name="description" content="">\n <meta name="keywords"
content="">\n <link rel="icon" sizes="16x16 32x32 48x48"
type="image/png" href="../../images/logos/favicon.png">\n <link
href="rss.search?sortBy=changeDate" rel="alternate"
type="application/rss+xml" title="My GeoNetwork catalogue - My
organization">\n <link href="portal.opensearch" rel="search"
type="application/opensearchdescription+xml" title="My GeoNetwork
catalogue - My organization">\n <link href="/geonetwork/static/gn_login_default.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/bootstrap-table.min.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/ng-skos.css"
rel="stylesheet" media="screen">\n <link href="/geonetwork/static/srv_custom_style.css"
rel="stylesheet" media="screen">\n </head>\n <body
data-ng-controller="GnCatController">\n <div class="navbar
navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar"
data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
<div data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
<div ng-include="\'../../catalog/templates/info.html\'"></div><script
src="/geonetwork/static/lib.js"></script><script
src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
class="alert" data-ng-hide=""><strong></strong> \n </div>\n
</noscript>\n </body>\n</html>'

sorry for the noise...

Ernest.

Le 02/10/2017 à 10:53, Chiarello Ernest a écrit :

Hello all,

as i do not know yet how to use the geonetwork API, i use the owslib
library in order to send data to geonetwork. but metadata are not public,
and i need to change the acces permissions with the admin console
https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board

it is also possible to change acces permissions with the following
PostgreSQL queries, observed in the postgresql logs :

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId,
metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '5'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId,
metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '0'

LOG: execute S_14: insert into geonetwork.OperationAllowed (groupId,
metadataId, operationId) values ($1, $2, $3)
DETAIL: parameters: $1 = '1', $2 = '410', $3 = '1'

my questions :

- is it possible to do that with the REST API of geonetwork ?
- it is possible to send data to geonetwork with its API ?

at the moment, i did not succeed when i tried to use this API. it is here
to find the documentation, for example here :
https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw

but i only get HTML errors with the HttpRequester plugin of Mozilla :
GET http://localhost:8080/geonetwork/srv/api/0.1/me -> error 406
GET http://localhost:8080/geonetwork/srv/api/0.1/search/ping -> error 406

any help would be appreciated.

Ernest.

--
Ernest CHIARELLO - Ernest.Chiarello@anonymised.com
UMR6049 ThéMA - Théoriser et Modéliser pour Amé
<https://maps.google.com/?q=éMA+-+Théoriser+et+Modéliser+pour+Amé&entry=gmail&source=g&gt;
nager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66 Mob : 07 82 99 11 08

------------------------------------------------------------
------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoNetwork-users mailing list
GeoNetwork-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-users
GeoNetwork OpenSource is maintained at http://sourceforge.net/project
s/geonetwork

--

*Vriendelijke groeten / Kind regards,Jose García
<http://www.geocat.net/&gt;Veenderweg 136721 WD BennekomThe NetherlandsT: +31
(0)318 416664 <+31318416664> <https://www.facebook.com/geocatbv&gt;
<https://twitter.com/geocat_bv&gt;
<https://plus.google.com/u/1/+GeocatNetbv/posts&gt;Please consider the
environment before printing this email.*

Hi Jose,

thanks for your answer, but i still have problems with the API : all the requests lead to the same result !

for example, http://localhost:8080/geonetwork/api/0.1/records should "Return the catalog content as RDF", according to the documentation.
but the content is always identical.

>>> import requests
>>> r = requests.get("http://localhost:8080/geonetwork/api/0.1/records&quot;\)
>>> print(r.status_code)
200
>>> print(r.content)
<!DOCTYPE html
SYSTEM "html">
<html ng-app="gn_login" lang="eng" id="ng-app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My GeoNetwork catalogue - My organization</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../images/logos/favicon.png">
<link href="rss.search?sortBy=changeDate" rel="alternate" type="application/rss+xml" title="My GeoNetwork catalogue - My organization">
<link href="portal.opensearch" rel="search" type="application/opensearchdescription+xml" title="My GeoNetwork catalogue - My organization">
<link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" media="screen">
</head>
<body data-ng-controller="GnCatController">
<div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar" data-ng-include="'../../catalog/templates/top-toolbar.html'"></div>
<div data-ng-include="'../../catalog/templates/signin.html'"></div>
<div ng-include="'../../catalog/templates/info.html'"></div><script src="/geonetwork/static/lib.js"></script><script src="/geonetwork/static/gn_login.js"></script><noscript>
<div class="alert" data-ng-hide=""><strong></strong>
</div>
</noscript>
</body>
</html>

same result with httprequester.
and my geonetwork contains metadata! (thanks to https://github.com/geonetwork/docker-geonetwork)

thanks in advance for your help.

Ernest.

Le 02/10/2017 à 12:16, Jose Garcia a écrit :

Hi

In current version there's a mix of "old" services using Jeeves engine (the ones using /srv/) and new API services that use /api/.

Old services are mark in the source code as @Deprecated and will be removed in next versions. Afaik in 3.4.x (next version) will be still available, but when released the following one (3.6 or whatever name it gets) most probably will be removed.

The plan is to migrate all services to the new API.

You can check/test current services in http://localhost:8080/geonetwork/doc/api/

Regards,
Jose García

On Mon, Oct 2, 2017 at 12:12 PM, Chiarello Ernest <Ernest.Chiarello@anonymised.com <mailto:Ernest.Chiarello@anonymised.com>> wrote:

    oups, it seems that the string SRV should not be used !

    localhost:8080/geonetwork/srv/cswis correct :

    >>> urllib2.urlopen("http://localhost:8080/geonetwork/srv/csw
    <http://localhost:8080/geonetwork/srv/csw&gt;&quot;\).read()
    '<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login"
    lang="eng" id="ng-app">\n <head>\n <meta
    http-equiv="Content-Type" content="text/html; <title>My GeoNetwork
    catalogue - My organization</title>\n <meta
    charset="utf-8">\n <meta name="viewport"
    content="initial-scale=1.0, user-scalable=no">\n <meta
    name="apple-mobile-web-app-capable" content="yes">\n <meta
    name="description" content="">\n <meta name="keywords"
    content="">\n <link rel="icon" sizes="16x16 32x32 48x48"
    type="image/png" href="../../images/logos/favicon.png">\n <link
    href="rss.search?sortBy=changeDate" rel="alternate"
    type="application/rss+xml" title="My GeoNetwork catalogue - My
    organization">\n <link href="portal.opensearch" rel="search"
    type="application/opensearchdescription+xml" title="My GeoNetwork
    catalogue - My organization">\n <link
    href="/geonetwork/static/gn_login_default.css" rel="stylesheet"
    media="screen">\n <link
    href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet"
    media="screen">\n <link href="/geonetwork/static/ng-skos.css"
    rel="stylesheet" media="screen">\n <link
    href="/geonetwork/static/srv_custom_style.css" rel="stylesheet"
    media="screen">\n </head>\n <body
    data-ng-controller="GnCatController">\n <div class="navbar
    navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar"
    data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
    <div
    data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
    <div
    ng-include="\'../../catalog/templates/info.html\'"></div><script
    src="/geonetwork/static/lib.js"></script><script
    src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
    class="alert" data-ng-hide=""><strong></strong> \n </div>\n
    </noscript>\n </body>\n</html>'

    but localhost:8080/geonetwork/srv/api/0.1/usersis not correct.

    >>>
    urllib2.urlopen("http://localhost:8080/geonetwork/srv/api/0.1/users
    <http://localhost:8080/geonetwork/srv/api/0.1/users&gt;&quot;\).read()
    Traceback (most recent call last):
     File "<stdin>", line 1, in <module>
     File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
     return opener.open(url, data, timeout)
     File "/usr/lib/python2.7/urllib2.py", line 435, in open
     response = meth(req, response)
     File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
     'http', request, response, code, msg, hdrs)
     File "/usr/lib/python2.7/urllib2.py", line 473, in error
     return self._call_chain(*args)
     File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
     result = func(*args)
     File "/usr/lib/python2.7/urllib2.py", line 556, in
    http_error_default
     raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 406: Not Acceptable

    remove "srv", and it works fine !

    >>>
    urllib2.urlopen("http://localhost:8080/geonetwork/api/0.1/users
    <http://localhost:8080/geonetwork/api/0.1/users&gt;&quot;\).read()
    '<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login"
    lang="eng" id="ng-app">\n <head>\n <meta
    http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
    <title>My GeoNetwork catalogue - My organization</title>\n <meta
    charset="utf-8">\n <meta name="viewport"
    content="initial-scale=1.0, user-scalable=no">\n <meta
    name="apple-mobile-web-app-capable" content="yes">\n <meta
    name="description" content="">\n <meta name="keywords"
    content="">\n <link rel="icon" sizes="16x16 32x32 48x48"
    type="image/png" href="../../images/logos/favicon.png">\n <link
    href="rss.search?sortBy=changeDate" rel="alternate"
    type="application/rss+xml" title="My GeoNetwork catalogue - My
    organization">\n <link href="portal.opensearch" rel="search"
    type="application/opensearchdescription+xml" title="My GeoNetwork
    catalogue - My organization">\n <link
    href="/geonetwork/static/gn_login_default.css" rel="stylesheet"
    media="screen">\n <link
    href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet"
    media="screen">\n <link href="/geonetwork/static/ng-skos.css"
    rel="stylesheet" media="screen">\n <link
    href="/geonetwork/static/srv_custom_style.css" rel="stylesheet"
    media="screen">\n </head>\n <body
    data-ng-controller="GnCatController">\n <div class="navbar
    navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar"
    data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
    <div
    data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
    <div
    ng-include="\'../../catalog/templates/info.html\'"></div><script
    src="/geonetwork/static/lib.js"></script><script
    src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
    class="alert" data-ng-hide=""><strong></strong> \n </div>\n
    </noscript>\n </body>\n</html>'

    sorry for the noise...

    Ernest.

    Le 02/10/2017 à 10:53, Chiarello Ernest a écrit :

        Hello all,

        as i do not know yet how to use the geonetwork API, i use the
        owslib library in order to send data to geonetwork. but
        metadata are not public, and i need to change the acces
        permissions with the admin console
        https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board
        <https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board>

        it is also possible to change acces permissions with the
        following PostgreSQL queries, observed in the postgresql logs :

        LOG: execute S_14: insert into geonetwork.OperationAllowed
        (groupId, metadataId, operationId) values ($1, $2, $3)
        DETAIL: parameters: $1 = '1', $2 = '410', $3 = '5'

        LOG: execute S_14: insert into geonetwork.OperationAllowed
        (groupId, metadataId, operationId) values ($1, $2, $3)
        DETAIL: parameters: $1 = '1', $2 = '410', $3 = '0'

        LOG: execute S_14: insert into geonetwork.OperationAllowed
        (groupId, metadataId, operationId) values ($1, $2, $3)
        DETAIL: parameters: $1 = '1', $2 = '410', $3 = '1'

        my questions :

        - is it possible to do that with the REST API of geonetwork ?
        - it is possible to send data to geonetwork with its API ?

        at the moment, i did not succeed when i tried to use this API.
        it is here to find the documentation, for example here :
        https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw
        <https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw&gt;

        but i only get HTML errors with the HttpRequester plugin of
        Mozilla :
        GET http://localhost:8080/geonetwork/srv/api/0.1/me
        <http://localhost:8080/geonetwork/srv/api/0.1/me&gt; -> error 406
        GET http://localhost:8080/geonetwork/srv/api/0.1/search/ping
        <http://localhost:8080/geonetwork/srv/api/0.1/search/ping&gt; ->
        error 406

        any help would be appreciated.

        Ernest.

    -- Ernest CHIARELLO - Ernest.Chiarello@anonymised.com
    <mailto:Ernest.Chiarello@anonymised.com>
    UMR6049 ThéMA - Théoriser et Modéliser pour Amé
    <https://maps.google.com/?q=éMA+-+Théoriser+et+Modéliser+pour+Amé&entry=gmail&source=g&gt;nager
    CNRS / université de Bourgogne Franche-Comté
    32 rue Mégevand 25030 BESANÇON Cedex

    Tel : 03 81 66 53 66 Mob : 07 82 99 11 08

    ------------------------------------------------------------------------------
    Check out the vibrant tech community on one of the world's most
    engaging tech sites, Slashdot.org! http://sdm.link/slashdot
    _______________________________________________
    GeoNetwork-users mailing list
    GeoNetwork-users@lists.sourceforge.net
    <mailto:GeoNetwork-users@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/geonetwork-users
    <https://lists.sourceforge.net/lists/listinfo/geonetwork-users&gt;
    GeoNetwork OpenSource is maintained at
    http://sourceforge.net/projects/geonetwork
    <http://sourceforge.net/projects/geonetwork&gt;

--
***
Vriendelijke groeten / Kind regards,

Jose García

<http://www.geocat.net/&gt;
Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664 <tel:+31318416664>

<https://www.facebook.com/geocatbv&gt;&lt;https://twitter.com/geocat_bv&gt;&lt;https://plus.google.com/u/1/+GeocatNetbv/posts&gt;

Please consider the environment before printing this email.
***

--
Ernest CHIARELLO -Ernest.Chiarello@anonymised.com
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66 Mob : 07 82 99 11 08

hi all,

no answser... well, perhaps should i ask my question in an other list, like geonetwork-devel ?
but it does not matter, we found 2 solutions ! :slight_smile:

1 :
import requests
headers = {'Accept': 'application/rdf+xml'}
r = requests.get("http://localhost:8080/geonetwork/srv/api/0.1/records&quot;, headers=headers)
r.content

2 :
import urllib2
import rdflib
uri = 'http://localhost:8080/geonetwork/srv/api/0.1/records
request_headers = {'Accept': 'application/rdf+xml'}
request = urllib2.Request(uri, headers = request_headers)
response = urllib2.urlopen(request)
data = response.read()
print(data)

hope it helps,

Ernest.

Le 03/10/2017 à 16:20, Chiarello Ernest a écrit :

Hi Jose,

thanks for your answer, but i still have problems with the API : all the requests lead to the same result !

for example, http://localhost:8080/geonetwork/api/0.1/records should "Return the catalog content as RDF", according to the documentation.
but the content is always identical.

>>> import requests
>>> r = requests.get("http://localhost:8080/geonetwork/api/0.1/records&quot;\)
>>> print(r.status_code)
200
>>> print(r.content)
<!DOCTYPE html
SYSTEM "html">
<html ng-app="gn_login" lang="eng" id="ng-app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My GeoNetwork catalogue - My organization</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../images/logos/favicon.png">
<link href="rss.search?sortBy=changeDate" rel="alternate" type="application/rss+xml" title="My GeoNetwork catalogue - My organization">
<link href="portal.opensearch" rel="search" type="application/opensearchdescription+xml" title="My GeoNetwork catalogue - My organization">
<link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="screen">
<link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" media="screen">
</head>
<body data-ng-controller="GnCatController">
<div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar" data-ng-include="'../../catalog/templates/top-toolbar.html'"></div>
<div data-ng-include="'../../catalog/templates/signin.html'"></div>
<div ng-include="'../../catalog/templates/info.html'"></div><script src="/geonetwork/static/lib.js"></script><script src="/geonetwork/static/gn_login.js"></script><noscript>
<div class="alert" data-ng-hide=""><strong></strong>
</div>
</noscript>
</body>
</html>

same result with httprequester.
and my geonetwork contains metadata! (thanks to https://github.com/geonetwork/docker-geonetwork)

thanks in advance for your help.

Ernest.

Le 02/10/2017 à 12:16, Jose Garcia a écrit :

Hi

In current version there's a mix of "old" services using Jeeves engine (the ones using /srv/) and new API services that use /api/.

Old services are mark in the source code as @Deprecated and will be removed in next versions. Afaik in 3.4.x (next version) will be still available, but when released the following one (3.6 or whatever name it gets) most probably will be removed.

The plan is to migrate all services to the new API.

You can check/test current services in http://localhost:8080/geonetwork/doc/api/

Regards,
Jose García

On Mon, Oct 2, 2017 at 12:12 PM, Chiarello Ernest <Ernest.Chiarello@anonymised.com <mailto:Ernest.Chiarello@anonymised.com>> wrote:

oups, it seems that the string SRV should not be used \!

localhost:8080/geonetwork/srv/cswis correct :

&gt;&gt;&gt; urllib2\.urlopen\(&quot;http://localhost:8080/geonetwork/srv/csw
&lt;http://localhost:8080/geonetwork/srv/csw&gt;&quot;\)\.read\(\)
&#39;&lt;\!DOCTYPE html\\n  SYSTEM &quot;html&quot;&gt;\\n&lt;html ng\-app=&quot;gn\_login&quot;
lang=&quot;eng&quot; id=&quot;ng\-app&quot;&gt;\\n &lt;head&gt;\\n      &lt;meta
http\-equiv=&quot;Content\-Type&quot; content=&quot;text/html; &lt;title&gt;My GeoNetwork
catalogue \- My organization&lt;/title&gt;\\n &lt;meta
charset=&quot;utf\-8&quot;&gt;\\n      &lt;meta name=&quot;viewport&quot;
content=&quot;initial\-scale=1\.0, user\-scalable=no&quot;&gt;\\n &lt;meta
name=&quot;apple\-mobile\-web\-app\-capable&quot; content=&quot;yes&quot;&gt;\\n &lt;meta
name=&quot;description&quot; content=&quot;&quot;&gt;\\n      &lt;meta name=&quot;keywords&quot;
content=&quot;&quot;&gt;\\n      &lt;link rel=&quot;icon&quot; sizes=&quot;16x16 32x32 48x48&quot;
type=&quot;image/png&quot; href=&quot;\.\./\.\./images/logos/favicon\.png&quot;&gt;\\n &lt;link
href=&quot;rss\.search?sortBy=changeDate&quot; rel=&quot;alternate&quot;
type=&quot;application/rss\+xml&quot; title=&quot;My GeoNetwork catalogue \- My
organization&quot;&gt;\\n      &lt;link href=&quot;portal\.opensearch&quot; rel=&quot;search&quot;
type=&quot;application/opensearchdescription\+xml&quot; title=&quot;My GeoNetwork
catalogue \- My organization&quot;&gt;\\n &lt;link
href=&quot;/geonetwork/static/gn\_login\_default\.css&quot; rel=&quot;stylesheet&quot;
media=&quot;screen&quot;&gt;\\n      &lt;link
href=&quot;/geonetwork/static/bootstrap\-table\.min\.css&quot; rel=&quot;stylesheet&quot;
media=&quot;screen&quot;&gt;\\n      &lt;link href=&quot;/geonetwork/static/ng\-skos\.css&quot;
rel=&quot;stylesheet&quot; media=&quot;screen&quot;&gt;\\n      &lt;link
href=&quot;/geonetwork/static/srv\_custom\_style\.css&quot; rel=&quot;stylesheet&quot;
media=&quot;screen&quot;&gt;\\n   &lt;/head&gt;\\n &lt;body
data\-ng\-controller=&quot;GnCatController&quot;&gt;\\n &lt;div class=&quot;navbar
navbar\-default gn\-top\-bar&quot; data\-ng\-hide=&quot;layout\.hideTopToolBar&quot;

data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
<div
data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
<div
ng-include="\'../../catalog/templates/info.html\'"></div><script
src="/geonetwork/static/lib.js"></script><script
src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
class="alert" data-ng-hide=""><strong></strong> \n </div>\n
</noscript>\n </body>\n</html>'

but localhost:8080/geonetwork/srv/api/0\.1/usersis not correct\.

&gt;&gt;&gt;

urllib2.urlopen("http://localhost:8080/geonetwork/srv/api/0.1/users
<http://localhost:8080/geonetwork/srv/api/0.1/users&gt;&quot;\).read()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 556, in
http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 406: Not Acceptable

remove &quot;srv&quot;, and it works fine \!

&gt;&gt;&gt;

urllib2.urlopen("http://localhost:8080/geonetwork/api/0.1/users
<http://localhost:8080/geonetwork/api/0.1/users&gt;&quot;\).read()
'<!DOCTYPE html\n SYSTEM "html">\n<html ng-app="gn_login"
lang="eng" id="ng-app">\n <head>\n <meta
http-equiv="Content-Type" content="text/html; charset=UTF-8">\n
<title>My GeoNetwork catalogue - My organization</title>\n <meta
charset="utf-8">\n <meta name="viewport"
content="initial-scale=1.0, user-scalable=no">\n <meta
name="apple-mobile-web-app-capable" content="yes">\n <meta
name="description" content="">\n <meta name="keywords"
content="">\n <link rel="icon" sizes="16x16 32x32 48x48"
type="image/png" href="../../images/logos/favicon.png">\n <link
href="rss.search?sortBy=changeDate" rel="alternate"
type="application/rss+xml" title="My GeoNetwork catalogue - My
organization">\n <link href="portal.opensearch" rel="search"
type="application/opensearchdescription+xml" title="My GeoNetwork
catalogue - My organization">\n <link
href="/geonetwork/static/gn_login_default.css" rel="stylesheet"
media="screen">\n <link
href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet"
media="screen">\n <link href="/geonetwork/static/ng-skos.css"
rel="stylesheet" media="screen">\n <link
href="/geonetwork/static/srv_custom_style.css" rel="stylesheet"
media="screen">\n </head>\n <body
data-ng-controller="GnCatController">\n <div class="navbar
navbar-default gn-top-bar" data-ng-hide="layout.hideTopToolBar"
data-ng-include="\'../../catalog/templates/top-toolbar.html\'"></div>\n
<div
data-ng-include="\'../../catalog/templates/signin.html\'"></div>\n
<div
ng-include="\'../../catalog/templates/info.html\'"></div><script
src="/geonetwork/static/lib.js"></script><script
src="/geonetwork/static/gn_login.js"></script><noscript>\n <div
class="alert" data-ng-hide=""><strong></strong> \n </div>\n
</noscript>\n </body>\n</html>'

sorry for the noise\.\.\.

Ernest\.

Le 02/10/2017 à 10:53, Chiarello Ernest a écrit :

    Hello all,

    as i do not know yet how to use the geonetwork API, i use the
    owslib library in order to send data to geonetwork\. but
    metadata are not public, and i need to change the acces
    permissions with the admin console

https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board
<https://my_geonetwork_url/geonetwork/srv/fre/catalog.edit#/board>

    it is also possible to change acces permissions with the
    following PostgreSQL queries, observed in the postgresql logs :

    LOG:  execute S\_14: insert into geonetwork\.OperationAllowed
    \(groupId, metadataId, operationId\) values \($1, $2, $3\)
    DETAIL:  parameters: $1 = &#39;1&#39;, $2 = &#39;410&#39;, $3 = &#39;5&#39;

    LOG:  execute S\_14: insert into geonetwork\.OperationAllowed
    \(groupId, metadataId, operationId\) values \($1, $2, $3\)
    DETAIL:  parameters: $1 = &#39;1&#39;, $2 = &#39;410&#39;, $3 = &#39;0&#39;

    LOG:  execute S\_14: insert into geonetwork\.OperationAllowed
    \(groupId, metadataId, operationId\) values \($1, $2, $3\)
    DETAIL:  parameters: $1 = &#39;1&#39;, $2 = &#39;410&#39;, $3 = &#39;1&#39;

    my questions :

    \- is it possible to do that with the REST API of geonetwork ?
    \- it is possible to send data to geonetwork with its API ?

    at the moment, i did not succeed when i tried to use this API\.
    it is here to find the documentation, for example here :

https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw
<https://csw-nerc.ceda.ac.uk/geonetwork/doc/api/#!/csw/addVirtualCsw&gt;

    but i only get HTML errors with the HttpRequester plugin of
    Mozilla :
    GET http://localhost:8080/geonetwork/srv/api/0.1/me
    &lt;http://localhost:8080/geonetwork/srv/api/0.1/me&gt; \-&gt; error 406
    GET http://localhost:8080/geonetwork/srv/api/0.1/search/ping

<http://localhost:8080/geonetwork/srv/api/0.1/search/ping&gt; ->
error 406

    any help would be appreciated\.

    Ernest\.

\-\-     Ernest CHIARELLO  \- Ernest\.Chiarello@anonymised\.com
&lt;mailto:Ernest.Chiarello@anonymised.com&gt;
UMR6049 ThéMA \- Théoriser et Modéliser pour Amé

<https://maps.google.com/?q=éMA+-+Théoriser+et+Modéliser+pour+Amé&entry=gmail&source=g&gt;nager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66           Mob : 07 82 99 11 08

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoNetwork-users mailing list
GeoNetwork-users@lists.sourceforge.net
<mailto:GeoNetwork-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/geonetwork-users
<https://lists.sourceforge.net/lists/listinfo/geonetwork-users&gt;
GeoNetwork OpenSource is maintained at
http://sourceforge.net/projects/geonetwork
<http://sourceforge.net/projects/geonetwork&gt;

--
***
Vriendelijke groeten / Kind regards,

Jose García

<http://www.geocat.net/&gt;
Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664 <tel:+31318416664>

<https://www.facebook.com/geocatbv&gt;&lt;https://twitter.com/geocat_bv&gt;&lt;https://plus.google.com/u/1/+GeocatNetbv/posts&gt;

Please consider the environment before printing this email.
***

--
Ernest CHIARELLO - Ernest.Chiarello@anonymised.com
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex

Tel : 03 81 66 53 66 Mob : 07 82 99 11 08