# 400 error on sample code

**URL:** <https://discuss.gradle.org/t/400-error-on-sample-code/27390>\
**Category:** Help/Discuss\
**Tags:** not-a-bug\
**Created:** [June 17, 2018, 11:14pm UTC](https://discuss.gradle.org/t/400-error-on-sample-code/27390 "2018-06-17T23:14:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rollingw](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@rollingw](https://discuss.gradle.org/u/rollingw)\
**Post date:** [June 17, 2018, 11:14pm UTC](https://discuss.gradle.org/t/400-error-on-sample-code/27390/1 "2018-06-17T23:14:44Z")

</div>

I’m new to publishing and took sample code from the web as an experiment, using the OSS version of nexus, I touch 3 files in the ‘/root’ directory of my docker container and use the following json to describe the desired maven format:

{  
“libs”: [  
{  
“cfgName”: “uploadInternal1”  
, “groupId”: “com.prot.zbank.client”  
, “artifactId”: “client-model”  
, “version”: “0.0.8”  
, “jarLocation”: “client/client-model.jar”  
}  
, {  
“cfgName”: “uploadInternal2”  
, “groupId”: “com.prot.zbank.client”  
, “artifactId”: “client-model”  
, “classifier”: “test”  
, “version”: “0.0.8”  
, “jarLocation”: “client/unit-test.jar”  
}  
, {  
“cfgName”: “uploadInternal3”  
, “groupId”: “com.prot.zbank.client”  
, “artifactId”: “client-model”  
, “version”: “0.0.8”  
, “jarLocation”: “client/rest-api.jar”  
}

```
]
, "repoUrl": "http://localhost:8081/nexus/content/repositories/snapshots/"
, "repoUser": "admin"
, "repoPswd": "admin123"

```

}

Using the following code (slightly modified, to make it simplier):

apply plugin: ‘maven’  
def f = file(“upload-list.json”)  
def m = f.exists() ? new groovy.json.JsonSlurper().parse(f) : null  
task batchUpload() {  
}  
if (m == null || m.libs == null || m.libs.isEmpty()) {  
batchUpload.doLast {  
println “WARNING: no file to upload”  
}  
} else {  
m.libs.each { lib -\>  
configurations.create( “${lib.cfgName}” )  
if (lib.classifier == null) {  
artifacts.add("${lib.cfgName}", file("${lib.jarLocation}"))  
} else {  
artifacts.add("${lib.cfgName}", file("${lib.jarLocation}")) {  
setClassifier( “${lib.classifier}” )  
}  
}

```
    def repoUrl = 'http://localhost:8081/nexus/content/repositories/snapshots/';
    def repoUser = 'admin';
    def repoPswd = 'admin123'; 
    def classifier = lib.classifier == null ? "" : ("-" + lib.classifier)
    println "define task '${lib.cfgName}' to upload ${lib.jarLocation} to ${repoUrl} as ${lib.groupId}:${lib.artifactId}-${lib.version}${classifier}.jar"
    project.tasks.create("${lib.cfgName}", Upload.class) {
        configuration = configurations[lib.cfgName]
        repositories {
            mavenDeployer {
                repository(url: "${repoUrl}") {
                    authentication(userName: "${repoUser}", password: "${repoPswd}")
                }
                pom.version = "${lib.version}"
                pom.artifactId = "${lib.artifactId}"
                pom.groupId = "${lib.groupId}"
            }
        }
    }
    batchUpload.dependsOn "${lib.cfgName}"
}

```

}

I’m getting a 400 “bad request” error. I’ve successfully published using other code, so the gradle container can get through to the nexus OSS container, that’s not the issue. As I’m publishing to ‘snapshot’ and ‘snapshot’ is empty, I don’t see the reason why the above isn’t publishing, any suggestions are appreciated.
