400 Bad Request error⚓︎
You are receiving one of the following errors trying to publish an artifact to Central Repository:
-SNAPSHOT suffix in artifact version:
What went wrong: Execution failed for task ':publishJvmPublicationToSnapshotRepository'. > Failed to publish publication 'jvm' to repository 'Snapshot' > Could not PUT 'https://s01.oss.sonatype.org/content/repositories/snapshots/com/myproject/artifact01/1.0.0-alpha/myartifact-alpha.4.jar'. Received status code 400 from server: Bad Request
Wrong NXRM server (as groupId is registered in s01.oss.sonatype.org):
Failed to publish publication 'maven' to repository 'ossrh' Could not PUT 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/commymproject-1032/com/myproject/artifact01/1.0.0/maven-metadata.xml'. Received status code 400 from server: Bad Request
Wrong or nonexistent groupId:
Failed to publish publication 'maven' to repository 'mavenCentral' > Could not PUT 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/com/nonexistentgroupid/1.0.0/myartifact-1.0.0.aar'. Received status code 400 from server: Bad Request
-SNAPSHOT added without need:
Caused by: org.gradle.internal.resource.transport.http.HttpErrorStatusCodeException: Could not GET 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/com/myproject/rightgroupid/0.1-SNAPSHOT/maven-metadata.xml'. Received status code 400 from server: Bad Request
How can I fix it and be able to publish to the Central Repository?
There are multiple reasons why you are getting this error, please evaluate each of them below:
-SNAPSHOT suffix is missing or was added without need
If you want to publish a SNAPSHOT please check our documentation,
set the specific endpoints for the SNAPSHOT releases and set the suffix
-SNAPSHOT to your artifact's version.
If you want to publish a SNAPSHOT release, verify that you are adding the
-SNAPSHOT suffix to your artifact version and using the SNAPSHOT endpoint.
If you are not publishing a SNAPSHOT release, verify that you are NOT
-SNAPSHOT suffix to your artifact version and using the right endpoint.
You are trying to publish using the wrong NXRM server
Since last year, new projects are being hosted in the new server https://s01.oss.sonatype.org. If you are using an old documentation that may still be referring to the old NXRM server or setting the new server when is not needed because your groupId was previously registered in the old server.
Please update your pom.xml and configuration files with the right server
s01.oss.sonatype.org) depending on where your
groupId was registered, you can also check the NXRM server information in the
JIRA ticket used to register
You are trying to publish using a wrong groupId in your configuration
Please check your groupId in your pom.xml or publishing configuration file. This is a common error when a typo or maybe not using the groupId registered previously is used.
Confirm that the groupId is correctly set in your configuration and matches the one that you registered in the JIRA ticket.
If you still are getting a 400 HTTP error and none of the above solutions work for you, please create a ticket using this link.