REST Execution fails with status code 302

We are trying to rename Job of Jenkins using its REST API, in-spite of using correct REST Endpoint we get status code as 302 Found when using CURL. Postman works fine.

curl -v -X POST <jenkins_url>/job/<old_job_name>/doRename?newName=cr%20test -H 'Authorization: Basic E45tg646YWRtaW4tryu=' -H 'Cache-Control: no-cache' -H 'Jenkins-Crumb: <CSRF token>'

Status code when tested using CURL: HTTP/1.1 302 Found

As per this https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html, status code 302 means The requested resource resides temporarily under a different URI.

This is the issue with every Jenkins REST API.

It looks like in every Jenkins REST request there are two call made over HTTP/HTTPS the first call make appropriate changes are per request and second call confirms whether requested changes are made.

Important Note - Though it gives 302 status code, in background it serves the purpose. If my above statement is right then here it is failing at second call that confirm whether changes made.

Please suggest how would I resolve this issue.

链接地址: http://www.djcxy.com/p/7936.html

上一篇: 输入excel文件?

下一篇: REST执行失败,状态码302