# Error 405 - Method not allowed while triggering job using API call

**URL:** <https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837>\
**Category:** Ask a question\
**Created:** [June 6, 2023, 10:07am UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837 "2023-06-06T10:07:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![inspell](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@inspell](https://community.jenkins.io/u/inspell)\
**Post date:** [June 6, 2023, 10:07am UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837/1 "2023-06-06T10:07:19Z")

</div>

Hi team!  
Could you advise how the following can be troubleshooted:  
curl -I -u myuser:MY USER TOCKEN ADDED HERE “[http://jenkins-lab.com/job/test/build?token=JOB](http://jenkins-lab.com/job/test/build?token=JOB) TOKEN ADDED HERE”

The output message I get is:  
HTTP/1.1 405 Method Not Allowed  
Date: Tue, 06 Jun 2023 09:48:50 GMT  
Server: Jetty(9.4.43.v20210629)  
X-Content-Type-Options: nosniff  
Content-Type: text/html;charset=utf-8  
Expires: Thu, 01 Jan 1970 00:00:00 GMT  
Cache-Control: no-cache,no-store,must-revalidate  
X-Hudson-Theme: default  
Referrer-Policy: same-origin  
Cross-Origin-Opener-Policy: same-origin  
X-Hudson: 1.395  
X-Jenkins: 2.332.1  
X-Jenkins-Session: 819be175  
X-Frame-Options: sameorigin  
X-Instance-Identity: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzUDrd2+8cn9YhLKSxM8uMXSgR0xetQ/sSwpAtAicsFb8yuiErH0kpdkGxIo1tj7CR+bXCVcJIWWKq0m9r4YofOLa/6cl2R7E3Ae+4vPK9XlkvV54W4bRnF/otaO/9SfO3ooU3OISaJMxnW7YVwQ11ZgOyshkHLblwKVhjc3xNsNhSlf6mtSCV7G+pKodw1O0vEyp+zkubgHxIgPWfO+gqbuol9glh18krDR1H2D1AP9izhNe0+lXoezEtp+LxdcVL1/6FPyG7lgz2IycoJuJV5g7/T9TcK5kDTGa+9VRSuaMQbZ3FQ+1cSnAEfQwkNoWawpwlbDNE1nruP4Nz0ITEQIDAQAB  
Transfer-Encoding: chunked  
Set-Cookie: JSESSIONID.28652b51=node06mhsaov3kwhzhsoe7tigr7jo3.node0; Path=/; HttpOnly

It happens so far only on one server that is version 2.332.1, no issue found on other servers that are running on versions 2.319.3 or 2.332.3.  
Is there way to get more detailed information what could cause the issue (I suspect it could be a plugin).

Thank you in advance!

Kind regards,

Nik

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [June 6, 2023, 12:17pm UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837/2 "2023-06-06T12:17:39Z")

</div>

Seems you’re doing a GET or HEAD request. That doesn’t work. You have to do a post request to trigger a build:  
`curl -X POST -u myuser:MY USER TOCKEN ADDED HERE “http://jenkins-lab.com/job/test/build?token=JOB TOKEN ADDED HERE”`

---

<div class="post-metadata">

**Author:** ![inspell](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@inspell](https://community.jenkins.io/u/inspell)\
**Post date:** [June 6, 2023, 1:32pm UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837/3 "2023-06-06T13:32:23Z")

</div>

Thank you for the reply but with the upper options it works for the rest of the servers just fine:  
Once the job is executed on other server we get this output:  
HTTP/1.1 201 Created  
Date: Tue, 06 Jun 2023 13:29:55 GMT  
Server: Jetty(9.4.43.v20210629)  
X-Content-Type-Options: nosniff  
Location: HIDDEN

When executing the suggested by you command on the working servers it triggers silently the build (no output but build is started).  
But on the same server where we hit the problem we get the following using the -X POST curl command:

Error 400 This page expects a form submission
## HTTP ERROR 400 This page expects a form submission

| URI: | /job/test/build |
| STATUS: | 400 |
| MESSAGE: | This page expects a form submission |
| SERVLET: | Stapler |

* * *
[Powered by Jetty:// 9.4.43.v20210629](https://eclipse.org/jetty)
* * *

So I suppose there is something in the configuration in the Jenkins master itself that causes the issue, but not sure how to get additional information what could be the problem.

---

<div class="post-metadata">

**Author:** ![mawinter69](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/mawinter69/32/1625_2.png) [@mawinter69](https://community.jenkins.io/u/mawinter69)\
**Post date:** [June 6, 2023, 3:02pm UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837/4 "2023-06-06T15:02:55Z")

</div>

Does the job have parameters? If yes you need to post to `...test/buildWithParameters`

---

<div class="post-metadata">

**Author:** ![inspell](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@inspell](https://community.jenkins.io/u/inspell)\
**Post date:** [June 7, 2023, 6:58am UTC](https://community.jenkins.io/t/error-405-method-not-allowed-while-triggering-job-using-api-call/7837/5 "2023-06-07T06:58:29Z")

</div>

You are time and life savior!! Thank you very much. Indeed the job was parametrized and using it with your suggestion works like a charm!
