-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem to insert metadata with Rest Api #8520
Comments
Hi! This error isn't giving much information so here's a couple of things to help you out:
Also, it would be very helpful if you could format your code snippets and logs a bit better in order to make easier for people to look at it 🙂 |
Hi i change the file now . --7617295b-9851-4b35-963e-cb0488cda4a7 <gmd:MD_Metadata xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gsr="http://www.isotc211.org/2005/gsr" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/csw/2.0.2/profiles/apiso/1.0.0/apiso.xsd"> --> END POST (56678-byte body) {"error": {
<-- END HTTP (145-byte body)
I put a log at the beginning of the rest method but it doesn't get called. I have nothing in the geonetwork log. Maybe I'm wrong in calling the rest method? |
Are you sure that there's absolutely no error showing up when you run the code above? And again, I'm quite sure that this API does not support multipart content. You could try creating a request body as an XML string: RequestBody requestBody = RequestBody.create(MediaType.parse("application/xml"), xmlOutputFile); (untested!) |
Yes no error found in the code execution geonetwork side , no error present in logger file; i use geonetwork localy. |
But without MultiPart i can't give a name for the property file.
</gmd:MD_Metadata> --> END POST (8220-byte body) <-- END HTTP (3455-byte body) here the code geonetwork side |
Oh sorry my bad, I thought the content-type has to be XML but I was looking at the wrong endpoint. I'm afraid that without more information (e.g. logs showing the error on GN side) it's very difficult to help you in any way. One thing you can try is importing the same XML file through the GeoNetwork interface and see if you also get a 500 error or not. If not, that means the problem comes from your code. Also for logs you should look at the output of the process running GeoNetwork: either the console if you're running it with Jetty, or the Application Container (e.g. Tomcat). The error should show up there. |
Hi ,
I'm trying to insert a metadata with the rest api.
I generated the client using the example described here : https://docs.geonetwork-opensource.org/3.12/api/the-geonetwork-api/#building-client-for-the-api-using-codegen.
Here the code :
try {
client.getHttpClient().networkInterceptors().add(new BasicAuthInterceptor(USERNAME, PASSWORD));
MeApi meApi = new MeApi(client);
ApiResponse apiResponse = meApi.getMeWithHttpInfo();
// client.getHttpClient().networkInterceptors().clear();
// client.getHttpClient().networkInterceptors().add(new XSRFInterceptor(apiResponse.getHeaders().get("Set-Cookie").getFirst().split(";")[0]));
List values = apiResponse.getHeaders().get("Set-Cookie");
String[] tokenValues = values.getFirst().split(";")[0].split("=");
String[] tokenJsessionID = values.get(1).split("=");
logger.info("##################TOKEN : {}\n", Arrays.toString(tokenValues));
logger.info("##################TOKEN_JSESSION_ID : {}\n", Arrays.toString(tokenJsessionID));
But the response code is 500 with empty response.
Here the debug for okhttpclient
--> POST http://localhost:8080/geonetwork/srv/api/records?metadataType=METADATA&uuidProcessing=NOTHING&publishToAll=true&assignToCatalog=true&transformWith=_none_ HTTP/1.1
Content-Type: multipart/form-data; boundary=219f4fc3-49c5-4042-9262-5cc9308d04bc
Content-Length: 8456
X-XSRF-TOKEN: 82a459bd-9c48-42c5-a26d-43f531f08519
--219f4fc3-49c5-4042-9262-5cc9308d04bc
Content-Disposition: form-data; name="file"; filename="example-of-actris-metadata.xml"
Content-Type: application/octet-stream
Content-Length: 8220
</gmd:MD_Metadata>
--219f4fc3-49c5-4042-9262-5cc9308d04bc--
--> END POST (8456-byte body)
<-- HTTP/1.1 500 Internal Server Error (80ms)
Alt-Svc: h3=":443"; ma=2592000
Cache-Control: no-cache
Content-Length: 0
Content-Security-Policy: frame-ancestors 'self'
Content-Type: text/html;charset=utf-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Expires: -1
Pragma: no-cache
Referrer-Policy: same-origin
Server: Caddy
Server: Jetty(9.4.56.v20240826)
Set-Cookie: serverTime=1732693181284; Path=/geonetwork
Set-Cookie: sessionExpiry=1732695281284; Path=/geonetwork
Strict-Transport-Security: max-age=31536000; includeSubdomains
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
Date: Wed, 27 Nov 2024 07:39:41 GMT
OkHttp-Sent-Millis: 1732693181261
OkHttp-Received-Millis: 1732693181340
<-- END HTTP (0-byte body)
08:39:41.341 [main] INFO o.g.d.m.c.DataciteJsonToCswConverterTest - Errore durante il caricamento del file: 500
How i can resolve??
Regards
Giuseppe
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Log file
If applicable, add the server log file to help trace your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: