Hi,
I’m getting HttpMediaTypeNotAcceptableException when trying to enter a new record through the API. My GN is v3.4.3.0 and the metadata XML file was prepared by exporting an existing entry.
The command I’m running:
curl -v -X POST "http://localhost:8080/geonetwork/srv/api/0.1/records?metadataType=METADATA&uuidProcessing=GENERATEUUID&rejectIfInvalid=false&publishToAll=true&assignToCatalog=false&transformWith=_none_" -H "accept: */*" -H "Content-Type: text/xml" -H "X-XSRF-TOKEN: c214a165-b862-82db-29c7-267676f4a895" --user admin:admin -b /tmp/cookie -d @path/to/metadata.xml
Log I’m getting:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
POST /geonetwork/srv/api/0.1/records?metadataType=METADATA&uuidProcessing=GENERATEUUID&rejectIfInvalid=false&publishToAll=true&assignToCatalog=false&transformWith=_none_ HTTP/1.1
Host: localhost:8080
Authorization: Basic YWRtaW46YWRtaW4=
User-Agent: curl/7.47.0
Cookie: XSRF-TOKEN=c214a165-b862-82db-29c7-267676f4a895
accept: */*
Content-Type: text/xml
X-XSRF-TOKEN: c214a165-b862-82db-29c7-267676f4a895
Content-Length: 10433
Expect: 100-continue
< HTTP/1.1 400 Bad Request
* Added cookie JSESSIONID="1vx9xfl6nv0tm1sm6otlczq1zx" for domain localhost, path /geonetwork, expire 0
< Set-Cookie: JSESSIONID=1vx9xfl6nv0tm1sm6otlczq1zx;Path=/geonetwork
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
* Added cookie serverTime="1542713381944" for domain localhost, path /, expire 0
< Set-Cookie: serverTime=1542713381944;Path=/
* Added cookie sessionExpiry="1542713381944" for domain localhost, path /, expire 0
< Set-Cookie: sessionExpiry=1542713381944;Path=/
< X-Frame-Options: DENY
< Content-Security-Policy: frame-ancestors 'none'
< Content-Type: application/xml
< Connection: close
< Server: Jetty(9.2.14.v20151106)
<
* Closing connection 0
The response I’m getting:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><apiError><code>runtime_exception</code><description>Could not find acceptable representation</description><message>HttpMediaTypeNotAcceptableException</message></apiError>
I’ve been fiddling with the Content-Type header, but to no avail. I don’t know what I’m doing wrong and don’t know what to try to solve my problem. Any clues or help would be appreciated!
Thanks!
Marko