1

I'm using Google Apps Script and using the DoubleClickCampaigns services v3.5, which allows me to use CM360 APIs v3.5

I'm trying to associate a creative to a campaign using campaignCreativeAssociations.insert()

  const profileId = '1234' //fake
  const campaignId = '12345'
  const creativeId = '5551234'
  DoubleClickCampaigns.CampaignCreativeAssociations.insert(profileId,campaignId,creativeId);

The above returns this error

 GoogleJsonResponseException: API call to dfareporting.campaignCreativeAssociations.insert failed with error: 8058 : Creative ID required.

Using the "Try this method" on the side bar of the documentation site has a sample code shows that I should instead pass in an object into the .insert parameter

 {"profileId":###,"campaignId",###,resource:{"creativeId":###}} 

Testing the code by running it on the documentation website (it works on live data) I can confirm that the creative was associated to the campaign.

function execute() {
    return gapi.client.dfareporting.campaignCreativeAssociations.insert({
      "profileId": 123,
      "campaignId": 456,
      "resource": {
        "creativeId": 123,
      }
    })

However when I try to rebuild the same code into my Apps Script environment, I get this error

DoubleClickCampaigns.CampaignCreativeAssociations.insert({
  "profileId": 123,
  "campaignId": 555,
  "resource": {
    "creativeId": 555123,
  }
})



Exception: Invalid number of arguments provided. Expected 3-4 only

Is the issue with the parameter? Following the sample code gives me an error regarding passing the wrong number of parameters. What should my code me so that I can use Apps Script to insert creatives into a CM360 campaign

kevhol
  • 35
  • 6

1 Answers1

1

It seems that the arguments of DoubleClickCampaigns.CampaignCreativeAssociations.insert() are as follows.

insert(resource: Dfareporting_v3_5.Dfareporting.V3_5.Schema.CampaignCreativeAssociation, profileId: string, campaignId: string)

When this is reflected to your script, how about the following modification?

Modified script:

var resource = { "creativeId": 555123 };
var profileId = "123";
var campaignId = "555"
DoubleClickCampaigns.CampaignCreativeAssociations.insert(resource, profileId, campaignId);
  • It seems that the values of profileId and campaignId are the string type.

Reference:

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Thank you! I've marked this as the correct answer. For further reference as I work more with APIs, how were you able to pull the arguments like the one you quoted above? Was it listed in the documentation? – kevhol Mar 08 '22 at 01:04
  • 1
    @kevhol Thank you for replying. In this case, I checked the arguments by the autocompletion of the script editor. For example, under enabling DoubleClickCampaigns API, when `DoubleClickCampaigns.CampaignCreativeAssociations.insert(` is inputted to the script editor, you can see the information in the opened dialog on the script editor. – Tanaike Mar 08 '22 at 01:10