VMware Cloud Community
shaharsib
Enthusiast
Enthusiast
Jump to solution

Create Jenkins http request + Crumb

Hi,

I already managed to get http request working properly - but only with CSRF Protection turned off.

normal http request with cURL command + CRUMB is looking something like this:

curl -X POST -H "Jenkins-Crumb:2e03fc96f387abggga6581fe5883a14a" http://My-Jenkins:8080/view/phase_2/job/test_remote_api_triggerring/buildWithParameters?token=MY_TOK... --user "username:password" 

In my vRO script the http request looks like this:

var jobRequest = restHost.createRequest("POST", jobUrlWithToken);

System.log("jobRequest:  " + jobRequest);

System.log("jobRequest full Url: " + jobRequest.fullUrl);

var jobRequestRes = jobRequest.execute();

which makes the https request looks like this:

http://My-Jenkins/job/Lease_Time_VCD_ENV/buildWithParameters?token=116985f3e7XXXXXXX45d279ee9f8&VAPP...

How and where should I placed the crumb token?

please help..

Tags (3)
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Add the line:

jobRequest.setHeader("Jenkins-Crumb", "2e03fc96f387abggga6581fe5883a14a");

before the line:

var jobRequestRes = jobRequest.execute();

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

View solution in original post

2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

Add the line:

jobRequest.setHeader("Jenkins-Crumb", "2e03fc96f387abggga6581fe5883a14a");

before the line:

var jobRequestRes = jobRequest.execute();

---------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.

shaharsib
Enthusiast
Enthusiast
Jump to solution

Helpful as always!

Many thanks!

0 Kudos