Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create an Image Ad #33

Closed
madpilot opened this issue Apr 17, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@madpilot
Copy link

commented Apr 17, 2019

We are having an issue creating a different type of ad (see #30): this time an image ad.

Using these params:

const b64 = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  const adId = await createAd({
    ad_group: adGroup,
    status: AdGroupAdStatus.PAUSED,
    ad: {
      name: "Image Ag",
      final_urls: [ "https://my.url", ],
      type: AdType.IMAGE_AD,
      image_ad: {
        image_url: "https://image.com/image.gif",
        pixel_width: 600,
        pixel_height: 600,
        preview_image_url: "https://image.com/preview.gif",
        preview_pixel_width: 600,
        preview_pixel_height: 600,
        name: "img.gif",
        mime_type: MimeType.IMAGE_GIF,
        data: b64
      }
    }

We get:

[ { wrappers_:
     { '1':
        { wrappers_:
           { '4':
              { wrappers_: null,
                messageId_: undefined,
                arrayIndexOffset_: -1,
                array: [ 'customers/4674531019/adGroups/74761353488' ],
                pivot_: 1.7976931348623157e+308,
                convertedFloatingPointFields_: {} },
             '5':
              { wrappers_:
                 { '2':
                    [ { wrappers_: null,
                        messageId_: undefined,
                        arrayIndexOffset_: -1,
                        array: [ 'https://www.realestate.com.au/agent/lucas-harwood-1227455?rsf=cid:reach:lucasharwood:recentlysoldengage' ],
                        pivot_: 1.7976931348623157e+308,
                        convertedFloatingPointFields_: {} } ],
                   '22':
                    { wrappers_:
                       { '2':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array:
                             [ Uint8Array [
                                 255,
                                 216,
                                 255,
                                 224,
                                 0,
                                 16,
                                 74,
                                 70,
                                 73,
                                 70,
                                 0,
                                 1,
                                 1,
                                 0,
                                 0,
                                 1,
                                 0,
                                 1,
                                 0,
                                 0,
                                 255,
                                 219,
                                 0,
                                 132,
                                 0,
                                 5,
                                 3,
                                 4,
                                 13,
                                 13,
                                 14,
                                 10,
                                 13,
                                 13,
                                 13,
                                 16,
                                 13,
                                 14,
                                 10,
                                 13,
                                 13,
                                 13,
                                 13,
                                 14,
                                 13,
                                 13,
                                 10,
                                 13,
                                 14,
                                 13,
                                 8,
                                 13,
                                 8,
                                 13,
                                 8,
                                 8,
                                 8,
                                 8,
                                 8,
                                 8,
                                 13,
                                 16,
                                 13,
                                 8,
                                 8,
                                 14,
                                 13,
                                 13,
                                 8,
                                 13,
                                 21,
                                 13,
                                 14,
                                 17,
                                 17,
                                 19,
                                 19,
                                 19,
                                 8,
                                 13,
                                 22,
                                 24,
                                 22,
                                 18,
                                 24,
                                 16,
                                 18,
                                 19,
                                 18,
                                 1,
                                 5,
                                 5,
                                 5,
                                 8,
                                 7,
                                 8,
                                 15,
                                 9,
                                 9,
                                 15,
                                 ... 14097 more items ] ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '4':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 600 ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '5':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 600 ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '6':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '7':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 600 ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '8':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 600 ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '9':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} },
                         '11':
                          { wrappers_: null,
                            messageId_: undefined,
                            arrayIndexOffset_: -1,
                            array: [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                            pivot_: 1.7976931348623157e+308,
                            convertedFloatingPointFields_: {} } },
                      messageId_: undefined,
                      arrayIndexOffset_: -1,
                      array:
                       [ <1 empty item>,
                         [ Uint8Array [
                             255,
                             216,
                             255,
                             224,
                             0,
                             16,
                             74,
                             70,
                             73,
                             70,
                             0,
                             1,
                             1,
                             0,
                             0,
                             1,
                             0,
                             1,
                             0,
                             0,
                             255,
                             219,
                             0,
                             132,
                             0,
                             5,
                             3,
                             4,
                             13,
                             13,
                             14,
                             10,
                             13,
                             13,
                             13,
                             16,
                             13,
                             14,
                             10,
                             13,
                             13,
                             13,
                             13,
                             14,
                             13,
                             13,
                             10,
                             13,
                             14,
                             13,
                             8,
                             13,
                             8,
                             13,
                             8,
                             8,
                             8,
                             8,
                             8,
                             8,
                             13,
                             16,
                             13,
                             8,
                             8,
                             14,
                             13,
                             13,
                             8,
                             13,
                             21,
                             13,
                             14,
                             17,
                             17,
                             19,
                             19,
                             19,
                             8,
                             13,
                             22,
                             24,
                             22,
                             18,
                             24,
                             16,
                             18,
                             19,
                             18,
                             1,
                             5,
                             5,
                             5,
                             8,
                             7,
                             8,
                             15,
                             9,
                             9,
                             15,
                             ... 14097 more items ] ],
                         <1 empty item>,
                         [ 600 ],
                         [ 600 ],
                         [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                         [ 600 ],
                         [ 600 ],
                         [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                         4,
                         [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ] ],
                      pivot_: 1.7976931348623157e+308,
                      convertedFloatingPointFields_: {} },
                   '23':
                    { wrappers_: null,
                      messageId_: undefined,
                      arrayIndexOffset_: -1,
                      array: [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                      pivot_: 1.7976931348623157e+308,
                      convertedFloatingPointFields_: {} } },
                messageId_: undefined,
                arrayIndexOffset_: -1,
                array:
                 [ <1 empty item>,
                   [ [ 'https://www.realestate.com.au/agent/lucas-harwood-1227455?rsf=cid:reach:lucasharwood:recentlysoldengage' ] ],
                   <2 empty items>,
                   14,
                   <4 empty items>,
                   [],
                   <5 empty items>,
                   [],
                   <5 empty items>,
                   [ <1 empty item>,
                     [ Uint8Array [
                         255,
                         216,
                         255,
                         224,
                         0,
                         16,
                         74,
                         70,
                         73,
                         70,
                         0,
                         1,
                         1,
                         0,
                         0,
                         1,
                         0,
                         1,
                         0,
                         0,
                         255,
                         219,
                         0,
                         132,
                         0,
                         5,
                         3,
                         4,
                         13,
                         13,
                         14,
                         10,
                         13,
                         13,
                         13,
                         16,
                         13,
                         14,
                         10,
                         13,
                         13,
                         13,
                         13,
                         14,
                         13,
                         13,
                         10,
                         13,
                         14,
                         13,
                         8,
                         13,
                         8,
                         13,
                         8,
                         8,
                         8,
                         8,
                         8,
                         8,
                         13,
                         16,
                         13,
                         8,
                         8,
                         14,
                         13,
                         13,
                         8,
                         13,
                         21,
                         13,
                         14,
                         17,
                         17,
                         19,
                         19,
                         19,
                         8,
                         13,
                         22,
                         24,
                         22,
                         18,
                         24,
                         16,
                         18,
                         19,
                         18,
                         1,
                         5,
                         5,
                         5,
                         8,
                         7,
                         8,
                         15,
                         9,
                         9,
                         15,
                         ... 14097 more items ] ],
                     <1 empty item>,
                     [ 600 ],
                     [ 600 ],
                     [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                     [ 600 ],
                     [ 600 ],
                     [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                     4,
                     [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ] ],
                   [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                   <2 empty items>,
                   [] ],
                pivot_: 1.7976931348623157e+308,
                convertedFloatingPointFields_: {} } },
          messageId_: undefined,
          arrayIndexOffset_: -1,
          array:
           [ <2 empty items>,
             3,
             [ 'customers/4674531019/adGroups/74761353488' ],
             [ <1 empty item>,
               [ [ 'https://www.realestate.com.au/agent/lucas-harwood-1227455?rsf=cid:reach:lucasharwood:recentlysoldengage' ] ],
               <2 empty items>,
               14,
               <4 empty items>,
               [],
               <5 empty items>,
               [],
               <5 empty items>,
               [ <1 empty item>,
                 [ Uint8Array [
                     255,
                     216,
                     255,
                     224,
                     0,
                     16,
                     74,
                     70,
                     73,
                     70,
                     0,
                     1,
                     1,
                     0,
                     0,
                     1,
                     0,
                     1,
                     0,
                     0,
                     255,
                     219,
                     0,
                     132,
                     0,
                     5,
                     3,
                     4,
                     13,
                     13,
                     14,
                     10,
                     13,
                     13,
                     13,
                     16,
                     13,
                     14,
                     10,
                     13,
                     13,
                     13,
                     13,
                     14,
                     13,
                     13,
                     10,
                     13,
                     14,
                     13,
                     8,
                     13,
                     8,
                     13,
                     8,
                     8,
                     8,
                     8,
                     8,
                     8,
                     13,
                     16,
                     13,
                     8,
                     8,
                     14,
                     13,
                     13,
                     8,
                     13,
                     21,
                     13,
                     14,
                     17,
                     17,
                     19,
                     19,
                     19,
                     8,
                     13,
                     22,
                     24,
                     22,
                     18,
                     24,
                     16,
                     18,
                     19,
                     18,
                     1,
                     5,
                     5,
                     5,
                     8,
                     7,
                     8,
                     15,
                     9,
                     9,
                     15,
                     ... 14097 more items ] ],
                 <1 empty item>,
                 [ 600 ],
                 [ 600 ],
                 [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                 [ 600 ],
                 [ 600 ],
                 [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
                 4,
                 [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ] ],
               [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
               <2 empty items>,
               [] ] ],
          pivot_: 1.7976931348623157e+308,
          convertedFloatingPointFields_: {} } },
    messageId_: undefined,
    arrayIndexOffset_: -1,
    array:
     [ [ <2 empty items>,
         3,
         [ 'customers/4674531019/adGroups/74761353488' ],
         [ <1 empty item>,
           [ [ 'https://www.realestate.com.au/agent/lucas-harwood-1227455?rsf=cid:reach:lucasharwood:recentlysoldengage' ] ],
           <2 empty items>,
           14,
           <4 empty items>,
           [],
           <5 empty items>,
           [],
           <5 empty items>,
           [ <1 empty item>,
             [ Uint8Array [
                 255,
                 216,
                 255,
                 224,
                 0,
                 16,
                 74,
                 70,
                 73,
                 70,
                 0,
                 1,
                 1,
                 0,
                 0,
                 1,
                 0,
                 1,
                 0,
                 0,
                 255,
                 219,
                 0,
                 132,
                 0,
                 5,
                 3,
                 4,
                 13,
                 13,
                 14,
                 10,
                 13,
                 13,
                 13,
                 16,
                 13,
                 14,
                 10,
                 13,
                 13,
                 13,
                 13,
                 14,
                 13,
                 13,
                 10,
                 13,
                 14,
                 13,
                 8,
                 13,
                 8,
                 13,
                 8,
                 8,
                 8,
                 8,
                 8,
                 8,
                 13,
                 16,
                 13,
                 8,
                 8,
                 14,
                 13,
                 13,
                 8,
                 13,
                 21,
                 13,
                 14,
                 17,
                 17,
                 19,
                 19,
                 19,
                 8,
                 13,
                 22,
                 24,
                 22,
                 18,
                 24,
                 16,
                 18,
                 19,
                 18,
                 1,
                 5,
                 5,
                 5,
                 8,
                 7,
                 8,
                 15,
                 9,
                 9,
                 15,
                 ... 14097 more items ] ],
             <1 empty item>,
             [ 600 ],
             [ 600 ],
             [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
             [ 600 ],
             [ 600 ],
             [ 'https://s3-ap-southeast-2.amazonaws.com/agent-reach-content-generator-staging/240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
             4,
             [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ] ],
           [ '240751-d18f6aed478f069039ba73fe5933e2b6e2041977.png' ],
           <2 empty items>,
           [] ] ] ],
    pivot_: 1.7976931348623157e+308,
    convertedFloatingPointFields_: {} } ]

The Mime Type field (id: 10) is missing.

Also: I'm not sure the best way to send that byte stream - as a decoded string?

@kritzware

This comment has been minimized.

Copy link
Member

commented Apr 17, 2019

Hi @madpilot,

Thanks for reporting this, these issues really are appreciated. I'm going to take a deeper look into this and find out what's going on, hopefully we'll be able to provide a quick fix like the previous issue!

As for the data field type, the Google Ads documentation specifies Bytes ("Raw image data as bytes."), and our protobuf ts compiler defines the type as string. So I think the way you've done it, by converting the image to a base64 string, should work fine. I'll double check this whilst fixing the mime_type issue.

By the way, if you want to make the output more readable when debugging, the protobuf grpc object should have a method .toObject(), which makes the resource much easier to parse 👍

@kritzware

This comment has been minimized.

Copy link
Member

commented Apr 17, 2019

I've released a new version (1.4.0), which includes upgrading the google-ads-node dependency.

I didn't seem to encounter any errors with the mime_type field, but instead discovered that in your example the ad.display_url field was missing, hence the "Missing required field" error being thrown.

It's definitely not very clear in the Google Ads documentation, or the error message, that the display_url is required. So in this release, we've added a new location property to the error object. This provides information on exactly which field is missing/invalid, and should hopefully make these kinds of errors easier to resolve in the future 🎉 You'd use it a bit like this:

try {
    await customer.adGroupAds.create(ad)
} catch (err) {
    if (err.code.adError === enums.AdError.EMPTY_FIELD) {
        console.log("Missing or invalid field:", err.location)
        // "Missing or invalid field: operations[0].create.ad.display_url"
    }
}

For the data field, I used a base64 string and it seems to work fine. Below is a full example of adding an image ad, which works for me:

const ad = {
    ad_group: "customers/123/adGroups/321",
    status: enums.AdGroupAdStatus.PAUSED,
    ad: {
        final_urls: ["http://www.example.com"],
        type: enums.AdType.IMAGE_AD,
        name: "ad #1",
        display_url: "https://example.com",
        image_ad: {
            image_url: "https://image.com/image.png",
            pixel_width: 300,
            pixel_height: 250,
            mime_type: enums.MimeType.IMAGE_PNG,
            data: "yourBase64EncodedString=",
        },
    },
}

const { results } = await customer.adGroupAds.create(ad, { validate_only: true })

Remember to update google-ads-api to 1.4.0. If you continue to have issues adding image ads, feel free to re-open this issue! 👍

@kritzware kritzware closed this Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.