BingAds / BingAds-Python-SDK

Other
118 stars 164 forks source link

MethodNotFound Exception for CampaignManagementService #7

Closed radulucaciu closed 9 years ago

radulucaciu commented 9 years ago

Hello,

I am getting the following error *** MethodNotFound: Method not found: 'CampaignManagementService.BasicHttpBinding_ICampaignManagementService.__repr__' when trying to get a CampaignManagementService. The troublesome code being used is this:

def _build_campaign_service(self, account_id, customer_id):
        authorization_data = AuthorizationData(
            developer_token=BING_DEVELOPER_TOKEN,
            authentication=self.authentication,
            account_id=account_id,
            customer_id=customer_id,
        )

        campaign_service = ServiceClient(
            'CampaignManagementService',
            authorization_data=authorization_data,
            environment=BING_ENVIRONMENT
        )

        return campaign_service

All parameters for the call seem to be populated correctly. One more weird thing is that the only output I get is No handlers could be found for logger "suds.client", nothing else, and the application just hangs at that point. The only way I could see the error was by using ipdb.set_trace()

     266         campaign_service = ServiceClient(
     267             'CampaignManagementService',
     268             authorization_data=authorization_data,
     269             environment=BING_ENVIRONMENT
     270          )
     271
--> 272        return campaign_service

ipdb> campaign_service
*** MethodNotFound: Method not found: 'CampaignManagementService.BasicHttpBinding_ICampaignManagementService.__repr__'

I do not know where to start debugging the issue, any pointers would be greatly appreciated!

imagineful commented 9 years ago

Hi, are you using the 'production' env? I tried to reproduce locally, but haven't see the same error. do you have any problems when using other bingads services?

For the exceptions: could you please add a try block to catch the exceptions? below is an example: try: campaign_service = ServiceClient( 'CampaignManagementService', authorization_data=authorization_data, environment=BING_ENVIRONMENT ) print(campaign_service.service_url) except suds.WebFault as ex:

please add a break point or print the ex to check the exception details.

...

Thanks.

eric-urban commented 9 years ago

Regarding No handlers could be found for logger "suds.client", you can import logging as shown in this example: https://github.com/bing-ads-sdk/BingAds-Python-SDK/blob/master/examples/BingAdsPythonExamplesConsole/BingAdsPythonExamplesConsole/SearchUserAccounts.py#L9

9 #import logging 10 #logging.basicConfig(level=logging.INFO) 11 #logging.getLogger('suds.client').setLevel(logging.DEBUG)

I hope this helps!

radulucaciu commented 9 years ago

Hi gents

Yes, I am using the 'production' environment I am away from a computer now, but will try the suggestions and come back with more info.

imagineful commented 9 years ago

Hi I tried again today on my workstation, it works well on my side, for your function definition: def _build_campaign_service(self, account_id, customer_id) it will return a campaign_service instance without error. And I added more test to check if the methods of campaign service can work. Not sure what authentication method you are using, here I use PasswordAuthentication. below is my code:

def _build_campaign_service(account_id, customer_id):

    authorization_data = AuthorizationData(
        account_id=ACCOUNT_ID,
        customer_id=CUSTOMER_ID,
        developer_token=DEVELOPER_TOKEN,
        authentication=PasswordAuthentication(user_name=USER_NAME, password=PASSWORD)
    )

    campaign_service = ServiceClient(
        'CampaignManagementService',
        authorization_data=authorization_data,
        environment='production'
    )
    return campaign_service

test_campaign = _build_campaign_service(ACCOUNT_ID, CUSTOMER_ID)

test_get_campaigns = test_campaign.GetCampaignsByAccountId(ACCOUNT_ID)

I checked test_get_campaigns, it returned all the campaigns under the account id.

Thanks.

radulucaciu commented 9 years ago

Hi, this is quite weird:

ipdb> campaign_service
*** MethodNotFound: Method not found: 'CampaignManagementService.BasicHttpBinding_ICampaignManagementService.__repr__'
ipdb> campaign_service.service_url
'https://api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v9/CampaignManagementService.svc?singleWsdl'

It seems that it actually works - the reason I thought it was hanging was that, using this code to pull all the campaigns, it took a very long time to return all of them (10+ minutes), even though they are less than ten campaigns, all in the last 6 months.

I can't explain the error above - I am using the Oauth method and am getting the same issue both on my local development box and on our server (both are Ubuntu 12.x machines) I am using the following package versions.

bingads==9.3.4
suds-jurko==0.6

Oh well, as long as it works... I don't know if it's worth investigating this issue any further since I can get the results, I think it can be closed. However, if I could be of any use to help debugging it, I'd love to help.

Thanks for the suggestions!

imagineful commented 9 years ago

Thanks. If you have further problems please feel free to let us know.