But if i try to get the data from an json file and use it in the body, this error appear :
################################################################
Invoke-WebRequest : HTTP ERROR 400 This page expects a form submission
URI:/job/gci/build
STATUS:400
MESSAGE:This page expects a form submission
################################################################
I don’t know powershell so just guessing. My immediate guess is that your not POSTing to the new job, but I see the -Method
Are you just trying to trigger another job to run? Its super easy in pipeline, you just use the build directive. In freestyle I think its a downstream job, but that might only run when the job is finished.
If your trying to access the jenkins web urls, I think you need a crsf token. I’m not sure thats the case if you don’t have auth on (I guess depends on what $BuildHeaders contains). But if you have auth on, you want to use a users’s api key not a user’s password to do the rquest, that’ll bypass the crsf check.
also lastly, the “This page expects a form submission” makes me think that maybe its because your trying to post json and not do a form post (x-www-form-urlencoded) with parameters not json.