1

I need to call a WCF Rest Service passing JSON. The problem I can't figure out is I don't have name value pairs. I need to pass something like this (this is in SoapUI):

["SB2011-037","SB2013-028"]

I have been trying to use URLEncode and I am guessing that is not the way to go. I have also seen some stuff with urllib.quote but that doesn't seem right.

url = "http://server/testService/Services/Posse.svc/rest/GetDataByProjectNumbers"
values = urllib.urlencode({
    '': 'SB2013-028',
    '': 'SB2011-037',
        })
#data = urllib.urlencode(values)
request = urllib2.Request(url,data)
result = urllib2.urlopen(request)

Have tried a couple of things I have seen.

values = {["SB2011-037","SB2013-028"]}

values = urllib.urlencode({
    None: 'SB2013-028',
    None: 'SB2011-037',
        }) 

values = urllib.urlencode({
    '': 'SB2013-028',
    '': 'SB2011-037',
        }) 

Thanks very much.

  • seems like it's a matter of how your Rest Service is designed, I would think a name like 'GetDataByProjectNumber' would not accept a list of multiple numbers.. have you tried this: http://server/testService/Services/Posse.svc/rest/GetDataByProjectNumbers/SB2013-028/ Also your first example with urlib2 using the data parameter is actually sending a post request which is probably not what you want. See here http://stackoverflow.com/a/7750946/471339 – brobas Dec 12 '14 at 19:11
  • I would like to use a post because it is potentially sending a large amount of data. I would consider using SOAP, not sure how to begin there. It does accept JSON and can comfirm with SoapUI and get to work. For example in SoapUI I can pass this ["SB2011-037","SB2013-028"] and it works fine. – Bill Harvey Dec 15 '14 at 15:20

0 Answers0