Closed chadn closed 6 years ago
@chadn please try creating the InsertionOrder SUDS object and calling the operation without the 'Request' intermediate object. I was able to repro the 1001 error using factory.create("AddInsertionOrderRequest")
as you did, and then got past the 1001 error with code similar to the following:
insertion_order=self.master_customer_billing_service.factory.create('ns4:InsertionOrder')
insertion_order.AccountId = self.account_id
insertion_order.BookingCountryCode = country_code
insertion_order.Comment = comment or "--No Comment--"
insertion_order.StartDate = start_date.format("YYYY-MM-DD")
insertion_order.EndDate = end_date
insertion_order.PurchaseOrder = po_number
insertion_order.Name = budget_name.strip()
insertion_order.SpendCapAmount = budget
insertion_order.Status = None
nested_partial_errors = self.master_customer_billing_service.AddInsertionOrder(InsertionOrder=insertion_order)
Caveat: I used different values for AccountId, SpendCapAmount, etc, but was able to create the valid SOAP request without nested insertion orders.
I believe this is something confusion caused by Suds.
if you try below code
from suds.client import Client
url='https://clientcenter.api.sandbox.bingads.microsoft.com/Api/Billing/v12/CustomerBillingService.svc?singleWsdl'
client = Client(url)
print client
You will find the method for adding InsertionOrder is AddInsertionOrder(ns4:InsertionOrder InsertionOrder)
, this is also the same as shown in Eric's example.
AddInsertionOrder(AddInsertionOrderRequest)
is not defined at all, however, if you look into java or dotnet SDK, you will need to create AddInsertionOrderRequest object.
@eric-urban that works for me! thanks for the pointer.
@qitia that does not work for me, i just get <suds.client.Client object at 0x10b55ae10>
We have a complicated environment, so it may be something on our end. i tried wrapping with pformat(), vars(), dir() .. nothing yielded useful info. But I see how that approach could have led me to the same solution that @eric-urban shared.
When debugging our code I noticed that the SOAP request generated by 11.12.x contains an
InsertionOrder
inside anotherInsertionOrder
. The effect is that the response from bingads server contains error code 1001,The user is not authorized to perform this action
. When you manually submit the same SOAP request but with only one level of InsertionOrder, it works as expected.The problem appears to be with this SDK. I've developed a workaround that has 2 parts. First I'm using
InsertionOrderTagDeduplicatorPlugin
, a suds plugin to edit context.envelope on sending. Second is a fix to SDK via #93 to enable the plugin to work.Here's my calling code, simplified - an error is thrown at the last line without the plugin or without #93.
Here's the SOAP request with
InsertionOrder
inside anotherInsertionOrder
Here's a successful SOAP request and response