Uploading nar (maven plugin) file error - Sonatype Nexus Repository - Sonatype Community
Uploading nar (maven plugin) file error
post by jarrettammerman on Jun 14, 2024
Jarrett Ammerman
I’m trying upload a .nar file to a nexus repository using curl. I get the following error when attempting to do so:
400 Detected content type [application/zip, application/x-zip-compressed], but expected [application/vnd.iptc.g2.newsmessage+xml, application/xml]
I don’t have issues uploading .jar files with the same method so I’m wondering if anyone has any experience with uploading .nar files.
post by mpiggott on Jun 20, 2024
Matthew Piggott
You may need to turn off strict content type validation for the repository. The error message suggests content type detection is choosing the incorrect type.
post by David_Kugele on Dec 4, 2025
David Kugele I’m having the same issue and we turned off strict content type validation for the repo but we are still getting the error. We are running version 3.73.
post by David_Kugele on Feb 9
@mpiggott Is there anything I can try if turning off strict content type validation still doesn’t fix the issue?
post by mpiggott on Feb 10
Matthew Piggott
I don’t have a nar file, but searching suggests its simply a zip. So I rename an archive and use the automatically created maven-releases repository which has strict content-type validation disabled:
curl -v -X PUT -T foo.nar http://localhost:8081/repository/maven-releases/g/a/1/a-1.nar
I see:
< HTTP/1.1 201 Created
< Server: Nexus/3.90.0-SNAPSHOT (PRO)
< X-Content-Type-Options: nosniff
< Content-Security-Policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< X-XSS-Protection: 0
< Content-Length: 0
If I turn on Validate that all content uploaded to this repository is of a MIME type appropriate for the repository format in the repository configuration and retry then the result is as you describe:
< HTTP/1.1 400 Detected content type [application/zip, application/x-zip-compressed], but expected [application/vnd.iptc.g2.newsmessage+xml, application/xml]: /g/a/1/a-1.nar
< Server: Nexus/3.90.0-SNAPSHOT (PRO)
< X-Content-Type-Options: nosniff
< Content-Security-Policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< X-XSS-Protection: 0
< Content-Length: 0
This works as I would expect (though the detected content type is likely wrong), all I can really suggest is upgrading to a newer version of Nexus.
post by mpiggott on Feb 10
@David_Kugele if you’re a repo pro customer, I would suggest having one of your support contacts file a ticket with support.