I try to complete automatically my GeoNetwork catalog with a Java client. My metadata respect the ISO 19115 schema and the interactions are performed trough CSW.

To insert metadata, I send HTTP POST request. The content of my request respects the CSW XML request format. No matter the library (io, apache commons, geotools), I always have the same HTML response as follows:

<!DOCTYPE html
  SYSTEM "html">
<html ng-app="gn_login" lang="eng" id="ng-app">
      <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="../../i$
      <link href="rss.search?sortBy=changeDate" rel="alternate" type="applicati$
      <link href="portal.opensearch" rel="search" type="application/opensearchd$
      <link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" med$
      <link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" $
      <link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="scree$
      <link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" med$
   <body data-ng-controller="GnCatController">
      <div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTo$
      <div data-ng-include="'../../catalog/templates/signin.html'"></div>
      <div ng-include="'../../catalog/templates/info.html'"></div><script src="$
         <div class="alert" data-ng-hide=""><strong></strong>

I have already try to perform GET and POST requests on a folder jetty server with success. My GET request works with my GeoNetwork. But as soon as as I perform POST request, the response is this html sheet.

I have tried two types of POST requests. Login POST request (".../geonetwork/srv/fre/xml.user.login" OR ".../geonetwork/srv/fre/catalog.signin") with this XML:

<?xml version="1.0" encoding="UTF-8"?>

And insert POST request with an ISO 19115 metadata (".../geonetwork/srv/fre/csw-transaction" OR ".../geonetwork/srv/fre/metadata.insert") like that:

<?xml version="1.0" encoding="UTF-8"?>
<csw:Transaction service="CSW" version="2.0.2" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2">
                <gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:wms="http://www.opengis.net/wms" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xlink="http://www.w3.org/199$

No matter the type of the post request, I always have the html sheet as response. I start my GeoNetwork with the start.jar of jetty. Do you know how to directly request the server to execute the POST requests and to get an XML response as expected?

  • 2
    What's your POST content? Are you trying to interact through CSW? Can you give more details on your GeoNetwork instance – nmtoken Jun 7 '17 at 9:36
  • Please edit your question to add all these extra details – nmtoken Jun 7 '17 at 11:52

Maybe my answer to my own question can help you with the login request.

I use a POST request, sending login credentials in the Authorization header to the authorization endpoint geonetwork/srv/eng/catalog.signin. This also works for other requests directly to geonetwork resources.

I have not used CSW transactional requests so far, but would suspect it to work the same way.

EDIT: Another thing came to my mind and might explain the difference between GET and POST: Did you check, that your user has rights to use transaction on the respective datasets?


I did face the same issue again with my own implementation. Somehow, querying the catalog.signin endpoint didn't work for me now, when I want to reuse the response JSESSIONID to login to GeoNetwork.

What I had to do is to query http://localhost:8080/geonetwork/j_spring_security_check and exactly follow all 302 redirects with my HTTPClient including issued cookies (intermediate sessionid's). After I receive a fresh JSESSIONID from the last redirect, I can then use this one to query private GeoNetwork resources.

I use java.net.HttpURLConnection, which has a default follow redirect property, which I had to set to false: con.setInstanceFollowRedirects(false); This is due to the fact, that this does not seem to include cookies by default when doing redirects, so it does not work in this case and I had to do the redirects manually.

  • Thanks for your answer. I try to send my login credentials as admin directly to geonetwork/srv/eng/catalog.signin. The response is a 302 error but I get a cookie associated to my httpClient; And after, when I try to send a transactional request with the same httpClient (which has the cookie), I have again a 302 error (the request does not insert what I want). How can I get XML CSW standard responses? How can I know if I have the rights to send transactionnal requests? – victor.brinon Jun 14 '17 at 7:38
  • For the user rights: you can go to your GeoNetwork web interface -> admin console -> users and groups -> manage users. Your user should be at least Editor or Adminstrator, I guess. But since you say, you use an admin account for the post, I would expect it to work actually. – ulrich Jun 14 '17 at 8:14
  • According to here, you should be able to do all metadata creation with the admin profile. Maybe check if you can create records manually in the web interface. – ulrich Jun 14 '17 at 8:20
  • There is no problem to create or import metadata manually (when I am logged as admin with my browser). I have read your answer to your own question. How do you get the "Location", where do you find it? – victor.brinon Jun 14 '17 at 8:39
  • I succeded to display the error response and the cookie. But with a 302 error, I do not know how to display the new URL. – victor.brinon Jun 14 '17 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.