Code Monkey home page Code Monkey logo

Comments (2)

kritzware avatar kritzware commented on September 6, 2024 1

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! 👍

from google-ads-api.

kritzware avatar kritzware commented on September 6, 2024

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 👍

from google-ads-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.