Microsoft Advertising API returning empty for all requests

74 views Asked by At

I am trying to get a list of campaigns by account ID from Microsoft Advertising API. In my response I always get empty array, but I know that on my account I have one active campaign. I followed instructions for getting Access token. First I created App on Azure, got the ID and also I created secret. Microsoft Partner Number approved and verified, and app verified so Oauth2 flow seems to be working as expected.

I added the following permissions enter image description hereAfter that I finished with OAuth 2 steps for getting AccessToken. Retrieved Oauth2 code from user consent at url:

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={MY_APP_ID}&response_type=code&redirect_uri={MY_REDIRECT_URI}&response_mode=query&scope=openid%20offline_access%20https%3A%2F%2Fads.microsoft.com%2Fmsads.manage%20profile&prompt=consent'

Then converted code to access token and refresh token using url: https://login.microsoftonline.com/common/oauth2/v2.0/token

After this I got Access token, refresh token (for fetching new access token) and ID token. With this access token we didn’t have any problem to use API to fetch information from SearchAccounts, GetUsersInfo, SubmitGenerateReport,PollGenerateReport ...

The problem we are facing is the ability to list out all available campaigns from GetCampaignsByAccountId. Using This endpoint with the correct ids we are getting an empty array returned when there is one active campaign.

The endpoint being hit is : This is URL: https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/v13/CampaignManagementService.svc?wsdl

And the following SOAP body is passed in the request

    <s:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header xmlns="https://bingads.microsoft.com/CampaignManagement/v13">
    <Action mustUnderstand="1">GetCampaignsByAccountId</Action>
    <AuthenticationToken i:nil="false">{ACCESS TOKEN}</AuthenticationToken>
    <CustomerAccountId i:nil="false">{MY_ACCOUNT_ID}</CustomerAccountId>
    <CustomerId i:nil="false">{MY_CUSTOMER_ID}</CustomerId>
    <DeveloperToken i:nil="false">{DEVELOPER_TOKEN}</DeveloperToken>
  </s:Header>
  <s:Body>
    <GetCampaignsByAccountIdRequest xmlns="https://bingads.microsoft.com/CampaignManagement/v13">
            <AccountId>{MY_ACCOUNT_ID}</AccountId>
                          <CampaignType>Search</CampaignType>

    </GetCampaignsByAccountIdRequest>
  </s:Body>
</s:Envelope>

Additionally we have tried with all campaign types passed and without the Campaign Type seeing this is optional https://i.stack.imgur.com/pinRL.png

And this is response:

<s:Envelope
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <h:TrackingId
            xmlns:h="https://bingads.microsoft.com/CampaignManagement/v13">{TRACKING_ID}
        </h:TrackingId>
    </s:Header>
    <s:Body>
        <GetCampaignsByAccountIdResponse
            xmlns="https://bingads.microsoft.com/CampaignManagement/v13">
            <Campaigns
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
            </GetCampaignsByAccountIdResponse>
        </s:Body>
    </s:Envelope>

We have tried to use the SubmitGenerateReport for this campaign. We used the campaign id that we can see on Microsoft Advertising platform. With this id we have been able to generate report without any problem, and retrieve the data (eg impressions) which matches with the data that we can see on Microsoft Advertising.

Our question is are we missing some permissions in Azure App, are we doing something wrong in my OAuth 2 steps? Are we missing something in the SOAP request to retrieve the campaigns?

Any idea or suggestion would be very gratefully appreciated.

0

There are 0 answers