-1

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!

linusg
  • 6,289
  • 4
  • 28
  • 78
NosIreland
  • 91
  • 2
  • 8
  • Have you tried looking through the documentation linked from the [pycurl](http://pycurl.io/) page? What was unclear? There are even code examples. – larsks Mar 30 '16 at 21:04
  • I have looked at docs and was able to work out everything else but cannot figure out params. I have not used curl or pycurl before so it is all new to me and any pointers would be very helpful. – NosIreland Mar 30 '16 at 22:04
  • 1
    Show us what you have worked out. That will at least give us a place to start in our explanations. – Robᵩ Mar 30 '16 at 22:48

1 Answers1

-1

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)
NosIreland
  • 91
  • 2
  • 8