PHP sdk - GoogleImportJob Object did not create the correct XML Envelope

Josh 0 Reputation points
2023-07-12T11:40:37.6333333+00:00

I'm trying to use the GoogleImportJob object for the AddImportJobs operation, however, I got an error when submitting it to the api, upon viewing the actual soap envelope, it did not create the expected format. Why is that?

here is the php code:

$googleImportJob = new GoogleImportJob();
$googleImportJob->Name = "Google-Import-API-" . date('mdYHis');
$googleImportJob->Type = "GoogleImportJob";
$googleImportJob->CredentialId = //the credential id;
$googleImportJob->GoogleAccountId = //google account id;
$request = 
$request->ImportJobs = [$googleImportJob];
$GLOBALS['CampaignManagementProxy']->GetService()->AddImportJobs($request);

and here is the actual soap envelope being sent to the api, as you can see it did not populated the GoogleImportJob data.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://bingads.microsoft.com/CampaignManagement/v13" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Header>
      <ns1:CustomerAccountId>######3</ns1:CustomerAccountId>
      <ns1:CustomerId>#######</ns1:CustomerId>
      <ns1:DeveloperToken>######</ns1:DeveloperToken>
      <ns1:UserName />
      <ns1:Password />
      <ns1:AuthenticationToken>######</ns1:AuthenticationToken>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <ns1:AddImportJobsRequest>
         <ns1:ImportJobs>
            <ns1:ImportJob>
               <ns1:CreatedByUserId xsi:nil="true" />
               <ns1:CreatedByUserName xsi:nil="true" />
               <ns1:CreatedDateTimeInUTC xsi:nil="true" />
               <ns1:Frequency xsi:nil="true" />
               <ns1:Id xsi:nil="true" />
               <ns1:ImportOption xsi:nil="true" />
               <ns1:LastRunTimeInUTC xsi:nil="true" />
               <ns1:Name>Google-Import-API-07122023070346</ns1:Name>
               <ns1:NotificationEmail xsi:nil="true" />
               <ns1:NotificationType xsi:nil="true" />
               <ns1:Status xsi:nil="true" />
               <ns1:Type>GoogleImportJob</ns1:Type>
            </ns1:ImportJob>
         </ns1:ImportJobs>
      </ns1:AddImportJobsRequest>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I'm expecting the soap body would include the type attribute in the ImportJob node and the CredentialId and GoogleAccountId is also included like this:

<s:Body>
    <AddImportJobsRequest>
      <ImportJobs i:nil="false">
        <ImportJob i:type="GoogleImportJob">
          <Name i:nil="false">"Value"</Name>
          <CredentialId i:nil="false">"Value"</CredentialId>
          <GoogleAccountId i:nil="false">"Value"</GoogleAccountId>
        </ImportJob>
      </ImportJobs>
    </AddImportJobsRequest>
  </s:Body>
Microsoft Advertising API
Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
416 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.