2017-11-07 10 views
0

장고 응용 프로그램에 넣으려고하는 API를 통해 Bing Ads에서 보고서를 다운로드 할 수있는 파이썬 3.5.2 코드가 있습니다.Bing Ads API/Suds 파이썬 deserialise 매개 변수 오류

나는이 오류 수 (ReportRequest = report_request) SubmitGenerateReport를 호출 한 후 내가 장고 쉘을 통해 코드를 실행 :

:

Traceback (most recent call last): 
    File "C:\Python35-32\lib\site-packages\googleads\util.py", line 123, in PatchedHttpTransportSend 
    fp = self.u2open(u2request) 
    File "C:\Python35-32\lib\site-packages\suds\transport\http.py", line 132, in u2open 
    return url.open(u2request, timeout=tm) 
    File "C:\Python35-32\lib\urllib\request.py", line 472, in open 
    response = meth(req, response) 
    File "C:\Python35-32\lib\urllib\request.py", line 582, in http_response 
    'http', request, response, code, msg, hdrs) 
    File "C:\Python35-32\lib\urllib\request.py", line 510, in error 
    return self._call_chain(*args) 
    File "C:\Python35-32\lib\urllib\request.py", line 444, in _call_chain 
    result = func(*args) 
    File "C:\Python35-32\lib\urllib\request.py", line 590, in http_error_default 
    raise HTTPError(req.full_url, code, msg, hdrs, fp) 
urllib.error.HTTPError: HTTP Error 500: Internal Server Error 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Python35-32\lib\site-packages\suds\client.py", line 613, in send 
    reply = self.options.transport.send(request) 
    File "C:\Python35-32\lib\site-packages\suds\transport\https.py", line 66, in send 
    return HttpTransport.send(self, request) 
    File "C:\Python35-32\lib\site-packages\googleads\util.py", line 134, in PatchedHttpTransportSend 
    raise suds.transport.TransportError(e.msg, e.code, e.fp) 
suds.transport.TransportError: Internal Server Error 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
    File "C:\Users\joe.heffer\PycharmProjects\wisepanda\report\models.py", line 401, in query 
    report_submission = reporting_service_client.SubmitGenerateReport(ReportRequest=report_request) 
    File "C:\Python35-32\lib\site-packages\bingads\service_client.py", line 269, in __call__ 
    raise ex 
    File "C:\Python35-32\lib\site-packages\bingads\service_client.py", line 261, in __call__ 
    response = self.service_client.soap_client.service.__getattr__(self.name)(*args, **kwargs) 
    File "C:\Python35-32\lib\site-packages\suds\client.py", line 521, in __call__ 
    return client.invoke(args, kwargs) 
    File "C:\Python35-32\lib\site-packages\suds\client.py", line 581, in invoke 
    result = self.send(soapenv) 
    File "C:\Python35-32\lib\site-packages\suds\client.py", line 619, in send 
    description=tostr(e), original_soapenv=original_soapenv) 
    File "C:\Python35-32\lib\site-packages\suds\client.py", line 670, in process_reply 
    raise WebFault(fault, replyroot) 
suds.WebFault: Server raised fault: 'The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter https://bingads.microsoft.com/Reporting/v11:ReportRequest. The InnerException message was 'There was an error deserializing the object of type Microsoft.AdCenter.Advertiser.Reporting.Api.DataContracts.Request.ReportRequest. The value '' cannot be parsed as the type 'Int32'.'. Please see InnerException for more details.' 

내 SOAP 요청에 문제를 찾을 수

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="https://bingads.microsoft.com/Reporting/v11" xmlns:ns1="https://bingads.microsoft.com/Reporting/v11" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header> 
     <tns:CustomerAccountId>135071005</tns:CustomerAccountId> 
     <tns:CustomerId>257199989</tns:CustomerId> 
     <tns:DeveloperToken>BBD37VB98</tns:DeveloperToken> 
     <tns:Password>*************</tns:Password> 
     <tns:UserName>joe_heffer_sbx</tns:UserName> 
    </SOAP-ENV:Header> 
    <ns0:Body> 
     <ns1:SubmitGenerateReportRequest> 
     <ns1:ReportRequest xsi:type="ns1:KeywordPerformanceReportRequest"> 
      <ns1:ExcludeColumnHeaders>false</ns1:ExcludeColumnHeaders> 
      <ns1:ExcludeReportFooter>true</ns1:ExcludeReportFooter> 
      <ns1:ExcludeReportHeader>true</ns1:ExcludeReportHeader> 
      <ns1:Format>Csv</ns1:Format> 
      <ns1:Language>English</ns1:Language> 
      <ns1:ReportName>Bing Report</ns1:ReportName> 
      <ns1:ReturnOnlyCompleteData>false</ns1:ReturnOnlyCompleteData> 
      <ns1:Aggregation>Daily</ns1:Aggregation> 
      <ns1:Columns> 
       <ns1:KeywordPerformanceReportColumn>TimePeriod</ns1:KeywordPerformanceReportColumn> 
       <ns1:KeywordPerformanceReportColumn>Spend</ns1:KeywordPerformanceReportColumn> 
      </ns1:Columns> 
      <ns1:Filter> 
       <ns1:AdRelevance/> 
       <ns1:ExpectedCtr/> 
       <ns1:Keywords/> 
       <ns1:LandingPageExperience/> 
       <ns1:LanguageCode/> 
       <ns1:QualityScore/> 
      </ns1:Filter> 
      <ns1:Scope/> 
      <ns1:Sort/> 
      <ns1:Time> 
       <ns1:CustomDateRangeEnd> 
        <ns1:Day/> 
        <ns1:Month/> 
        <ns1:Year/> 
       </ns1:CustomDateRangeEnd> 
       <ns1:CustomDateRangeStart> 
        <ns1:Day/> 
        <ns1:Month/> 
        <ns1:Year/> 
       </ns1:CustomDateRangeStart> 
       <ns1:PredefinedTime>ThisYear</ns1:PredefinedTime> 
      </ns1:Time> 
     </ns1:ReportRequest> 
     </ns1:SubmitGenerateReportRequest> 
    </ns0:Body> 
</SOAP-ENV:Envelope> 

나는 단서 내가 구글 언급 점점 비눗물 오류 해요 있다는 것 같아요 (이 장고 앱 설치)도 비눗물을 사용하는 구글 API를 (.)

답변

0

문제 내 보고서 요청에 지정된 맞춤 기간 범위 매개 변수와 미리 정의 된 기간이 있다는 것입니다.

이 그들의 포럼에 마이크로 소프트 일 techie에 의해 확인되었다 :

# Build report request 
report_request = reporting_service_client.factory.create('KeywordPerformanceReportRequest') 
# Time range 
report_time = reporting_service_client.factory.create('ReportTime') 
report_time.PredefinedTime = 'ThisYear' 
del report_time.CustomDateRangeEnd 
del report_time.CustomDateRangeStart 
:

https://social.msdn.microsoft.com/Forums/en-US/9dc7be19-9ac7-4cba-8472-e79300cd6655/webfault-deserialize-parameter-in-python?forum=BingAds

해결책은 이것이다