1
from pysimplesoap.client import SoapClient
client = SoapClient(wsdl="https://platform.mediamind.com/Eyeblaster.MediaMind.API/V2/AuthenticationService.svc?wsdl")
auth_token = client.ClientLogin(username = 'user', password = 'pass',
                                 applicationKey = 'test')

#I got authenticated here

token=  auth_token['ClientLoginResult']

campaign_client =  SoapClient(wsdl="https://platform.mediamind.com/Eyeblaster.MediaMind.API/V2/CampaignService.svc?wsdl"
                                  ,trace = False)

There is simple method I want to call get contact definition below

Show    
    Parameters  

    Name    Type    Description
    ContactID   Int32   The contact ID. Mandatory field.
    UserSecurityToken   String  Contains a string that uniquely identifies the current Sizmek Trafficking API session. You may retrieve the token after logging into the AuthenticationService

_

Show    
Response    

Name    Type    Description
Contact     ContactInfo     Returns the contact information used by ContactInfo

I believe I am not able to pass parameters correctly here. That's why wrong request is formed

test = {'UserSecurityToken' :token,'ContactID' : 1  }
data = campaign_client.GetContact(test )

In WSDL client I can see the code below to get method with parameters.

def __getattr__(self, attr):
        """Return a pseudo-method that can be called"""
        if not self.services:  # not using WSDL?
            return lambda self=self, *args, **kwargs: self.call(attr, *args, **kwargs)
        else:  # using WSDL:
            return lambda *args, **kwargs: self.wsdl_call(attr, *args, **kwargs)
Forage
  • 2,726
  • 2
  • 18
  • 20
sagar
  • 1,375
  • 5
  • 20
  • 38
  • After using campaign_client.GetContact(UserSecurityToken=test['UserSecurityToken'], ContactId=test['ContactID']...still getting below error – sagar Apr 30 '15 at 08:19
  • Error:%s Invalid Args Structure. Errors: [u"Argument key UserSecurityToken not in parameter. parameter: {u'ContactID': }, args: {'ContactID': 1, 'UserSecurityToken': u'4bb80e33-ff69-486e-826f-b27ecd2396be'}"] – sagar Apr 30 '15 at 08:20

1 Answers1

2

You are trying to unpack keyword arguments from a dict, and you need to use **kwarg notation for that:

data = campaign_client.GetContact(**test)

Checkout this Python docs page: Unpacking Argument Lists

bosnjak
  • 8,424
  • 2
  • 21
  • 47
  • thanks @Lawrence but still getting error Error: %s Invalid Args Structure. Errors: [u"Argument key UserSecurityToken not in parameter. parameter: {u'ContactID': }, args: {'ContactID': 1, 'UserSecurityToken': u'f38e6844-e9e4-46fd-b0c0-68ff85e313e7'}"] error – sagar Apr 30 '15 at 07:26
  • The function is expecting to get UserSecurityToken as a parameter, so you will have to pass it without unpacking, ckeck the update. – bosnjak Apr 30 '15 at 07:31
  • @sagar: I removed the update, previous solution should work. Does this work: `campaign_client.GetContact(UserSecurityToken=test['UserSecurityToken'], ContactId=test['ConcactID'])`? – bosnjak Apr 30 '15 at 07:38
  • Also, check the value of `token`, it might be empty. Print it out after you create it. – bosnjak Apr 30 '15 at 07:39
  • no still geting Error:%s 'ConcactID' tryed to changing ConatactID to "1" also still same error – sagar Apr 30 '15 at 07:56
  • I also checked token its not empty – sagar Apr 30 '15 at 07:58
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76608/discussion-between-sagar-and-lawrence). – sagar Apr 30 '15 at 08:01
  • @sagar I would try to run this locally, but I don't have the credentials. Is there some kind of demo or testing credentials for use with this service? – bosnjak Apr 30 '15 at 15:01