jenkinsci / jenkinsci/java-client-api

Sending POST http request for Job.build(Map<String, String> params, boolean crumbFlag) with crumbFlag=true raised java.lang.IllegalArgumentException: Name may not be null

Open
#433 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
913
Forks
466
PR merge metrics
No merged PRs in 30d

Description

Hi, I am quiet new to Jenkins client API. I'm trying to use the `Job.build` method to kick off a parameterized job with `crumb` flag set to `true`.
However, it threw this exception:
```
java.lang.IllegalArgumentException: Name may not be null
at org.apache.http.util.Args.notNull(Args.java:54)
at org.apache.http.message.BasicHeader.(BasicHeader.java:61)
at com.offbytwo.jenkins.client.JenkinsHttpClient.post(JenkinsHttpClient.java:233)
at com.offbytwo.jenkins.model.Job.build(Job.java:151)
```

Inspecting further in `JenkinsHttpClient.java`, it looks like the issue is with crumb issuer path:
```
Crumb crumb = getQuietly("/crumbIssuer", Crumb.class);
```

Shouldn't this be `crumbIssuer/api/xml` or `crumbIssuer/api/json`??

I can't turn off CSRF in this Jenkins instance, so that's not an option. How can I workaround or fix this issue?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.