简体   繁体   中英

Using parameters with pycurl

I'm trying to use pycurl for the first time and I'm not sure how to use parameters with it.

curl "https://mytest.com/mdb.json" 
-H "Cookie: JSESSIONID=6CCB148AEE7318BD08EFC869E0FD33AB; user=testuser; wmUserPrincipal="%"7B"%"22username"%"22"%"3A"%"22testuser"%"22"%"2C"%"22roles"%"22"%"3A"%"5B"%"5D"%"7D; mf_user=322383eec941db6c72f3f2c7d58b7a80" 
-H "Content-Type: application/json-rpc" 
-H "Accept: */*" 
-H "X-Requested-With: XMLHttpRequest" 
-H "Connection: keep-alive" --data-binary "{""params"":[""1.2.1"",""instance7"",""1.2"",4,{}],""method"":""getMatrix"",""id"":250}" --compressed

As seen in the curl I have:

--data-binary "{""params"":[""1.2.1"",""instance7"",""1.2"",4,{}],""method"":""getMatrix"",""id"":250}" --compressed

and I cannot figure out what to do with them in pycurl . Maybe it is not even possible or maybe there is a simpler solution than using pycurl .

Thank you!

Got it running with requests which is a simpler and exactly what I needed.

cookie = {
    'JSESSIONID': '6CCB148AEE7318BD08EFC869E0FD33AB',
    'user': 'testuser',
    'wmUserPrincipal': '%7B%22username%22%3A%22testuser%22%2C%22roles%22%3A%5B%5D%7D',
    'mf_user': '322383eec941db6c72f3f2c7d58b7a80',
}

head = {
    'Content-Type': 'application/json-rpc',
    'Accept': '*/*',
    'X-Requested-With': 'XMLHttpRequest',
    'Connection': 'keep-alive',
}

data = '{"params":["1.2.1","instance7","1.2",4,{}],"method":"getMatrix","id":250}'

requests.post('https://mytest.com/mdb.json', headers=head, cookies=cookie, data=data)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM