You would have to implement a function to base64 encode the data (I should have mentioned that in my previous post).
On Tue, Jul 9, 2019 at 2:41 PM D. C. <[email protected]> wrote: > Thanks for the suggestions. I had actually already tried "HttpReq.Open > "POST", strJenkinsURL, False, strUsername, strPassword" and it didn't > help. Since the error returned has to do with the crumb (403 No valid > crumb was included), I hoped the auth part was actually working, but maybe > not. I have tried again with passing the username/password as part of the > Open method, but still no luck there. > > I tried the .setRequestHeader "Authentication" like you showed but it > returns "Type mismatch: 'Base64Encode'" so something is wrong with the > syntax. > > > On Tuesday, July 9, 2019 at 2:06:57 PM UTC-5, slide wrote: >> >> I think you want to pass the username/password as part of the Open method >> call >> >> HttpReq.Open "POST", strJenkinsURL, False, strUsername, strPassword >> >> In addition, you may need to set an Authorization header, but I am not >> sure how the MSXML2.ServerXMLHTTP object handles that if you pass the >> username/password with the Open call. >> >> You would need to do something like this if just passing it via the Open >> method doesn't work: >> >> HttpReq.setRequestHeader "Authentication", "Basic " & >> Base64Encode(strUsername & ":" & strPassword) >> >> On Tue, Jul 9, 2019 at 10:54 AM D. C. <[email protected]> wrote: >> >>> I have searched all over but haven't found a solution to this. The >>> JenkinsAPI page doesn't provide information on using VBScript either. >>> I am trying to start a job in Jenkins from a classic ASP web page (so >>> VBScript - code below). I used wget from examples on the Jenkins API page >>> to get the Jenkins crumb. The testjob is configured with "Trigger builds >>> remotely" and I included the token in the URL string as specified in the >>> examples on the Jenkins API page. I am unsure if the login information is >>> setup correctly in my .setRequestHeader, but the error I am getting is "No >>> valid crumb" even though I include the crumb in the header. Can anyone >>> tell me if the .setRequestHeaders are in the correct format or anything >>> else that might help me get this to work? I have also tried using curl to >>> start the job, but that doesn't start the job, but it also doesn't return >>> an error. From what I have found, curl should return an HTTP 201 response >>> to indicate the job was started. I'm not getting that. I would prefer to >>> start the job from VBScript; curl was just for a test. >>> >>> VBScript: >>> -------------- >>> Dim strJenkinsURL, HttpReq >>> strJenkinsURL = "http:// >>> <jenkinsURL>/job/testjob/buildWithParameters?token=test&Description=sometext" >>> >>> Set HttpReq = Server.CreateObject("MSXML2.ServerXMLHTTP") >>> HttpReq.Open "POST", strJenkinsURL, False >>> HttpReq.setRequestHeader "UserName", "<jenkinsuser>" >>> HttpReq.setRequestHeader "Password", "<userpassword>" >>> HttpReq.setRequestHeader "Jenkins-Crumb", "<validcrumb>" >>> HttpReq.Send >>> Response.Write "<br>Status: "& HttpReq.Status & vbNewline >>> Response.Write "<br>Response: "& HttpReq.responseText & vbNewline >>> >>> Result >>> --------------------- >>> Status: 403 >>> Response: HTTP ERROR 403 >>> Problem accessing /job/testjob/buildWithParameters. Reason: No valid >>> crumb was included in the request >>> >>> curl: >>> ------------------------ >>> curl -v --user <jenkinsuser>:<password> -X POST " >>> http://jenkinsurl/job/testjob/buildWithParameters?token=test&Description=sometext" >>> -H "Jenkins-Crumb:<crumb value>" >>> >>> * timeout on name lookup is not supported >>> * Trying xxx.xxx.xxx.xxx... >>> * TCP_NODELAY set >>> % Total % Received % Xferd Average Speed Time Time Time >>> Current >>> Dload Upload Total Spent Left >>> Speed >>> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- >>> --:--:-- 0* Connected to jenkinsurl (xxx.xxx.xxx.xxx) port 80 (#0) >>> * Server auth using Basic with user 'jenkinsuser' >>> > POST /job/testjob/buildWithParameters?token=test&Description=sometext >>> HTTP/1.1 >>> > Host: jenkinsurl >>> > Authorization: Basic Y3MyYXV0b3Rlc3Q6QXV0b21hdGlvbjE= >>> > User-Agent: curl/7.55.0 >>> > Accept: */* >>> > Jenkins-Crumb:<crumb value> >>> > >>> * HTTP 1.0, assume close after body >>> < HTTP/1.0 302 Found >>> < Location: >>> https://jenkinsurl/job/testjob/buildWithParameters?token=test&Description=sometext >>> < Server: BigIP >>> * HTTP/1.0 connection set to keep alive! >>> < Connection: Keep-Alive >>> < Content-Length: 0 >>> < >>> 0 0 0 0 0 0 0 0 --:--:-- --:--:-- >>> --:--:-- 0 >>> * Connection #0 to host jenkinsurl left intact >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Jenkins Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jenkinsci-users/acd05793-f5c3-47c1-9049-75835b7933a2%40googlegroups.com >>> <https://groups.google.com/d/msgid/jenkinsci-users/acd05793-f5c3-47c1-9049-75835b7933a2%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> Website: http://earl-of-code.com >> > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/40ab289f-2d68-465d-8c00-4791968a38a0%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/40ab289f-2d68-465d-8c00-4791968a38a0%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Website: http://earl-of-code.com -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVcYdQ6j0Ejuz1L-9ffCWW167y7knVVDuz1Vy7bu_4xgew%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
