[Chennaipy] Require help in code

Bharathwaaj S bharath at testpress.in
Fri Feb 23 05:22:29 EST 2018


Try using session.

import requests,time,json

session = requests.Session()
adapter = requests.adapters.HTTPAdapter(max_retries = 5)
session.mount('http://', adapter)

fobj = open("file")
for x in fobj:
       x = x.replace("\n", "")
       url="https://username:password@localhost/jenkins/job/job-name/
buildWithParameters"
       params = {'BRANCH':x}
       headers = {"Content-Type": "application/xml"}
       r = *session*.post(url , params=params, verify=False)
       print(r.status_code)
       print(r.text)
       #time.sleep(45)
fobj.close()



On Fri, Feb 23, 2018 at 3:37 PM, Karthikeyan S <karthik120 at gmail.com> wrote:

> Yes, via CURL command it works perfectly.
>
> On Fri, Feb 23, 2018 at 3:13 PM, Shrayas rajagopal <shrayasr at gmail.com>
> wrote:
>
>> Hi Karthikeyan,
>>
>> On Fri, Feb 23, 2018 at 3:02 PM, Karthikeyan S <karthik120 at gmail.com>
>> wrote:
>>
>> [...]
>>
>> > Could you please help ?
>>
>> Are you able to execute the same thing outside of python? i.e. with
>> another RESTful client like postman?
>>
>> Regards,
>> Shrayas
>> _______________________________________________
>> Chennaipy mailing list
>> Chennaipy at python.org
>> https://mail.python.org/mailman/listinfo/chennaipy
>>
>
>
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chennaipy/attachments/20180223/97f1171e/attachment-0001.html>


More information about the Chennaipy mailing list