BingAds / BingAds-Python-SDK

Other
118 stars 164 forks source link

Error Parsing "Start Date" Column for BulkAssetGroup #302

Open VadimSaratov opened 1 week ago

VadimSaratov commented 1 week ago

When attempting to download and parse the BulkAssetGroup object, the SDK throws an error related to the Start Date column.

[ERROR] [BulkServiceManager.EntityReadException] Couldn't parse column Start Date of <class 'bingads.v13.bulk.entities.bulk_asset_group.BulkAssetGroup'> entity: unconverted data remains:  00:00:00 See ColumnValues for detailed row information and InnerException for error details.

It cannot process the Start Date column when the format is YYYY-MM-DD HH:MM:SS. It appears the BulkAssetGroup expects the date format to be YYYY-MM-DD Probably the same issue with End Date

Or is it a bug with CSV generation?

If the issue is the date format, then Suggested Fix: Update the BulkAssetGroup to handle datetime formats in the Start Date and End Date columns.

        _SimpleBulkMapping(
            header=_StringTable.StartDate,
            field_to_csv=lambda c: bulk_datetime_str(c.asset_group.StartDate),
            csv_to_field=lambda c, v: setattr(c.asset_group, 'StartDate', parse_datetime(v))
        ),
        _SimpleBulkMapping(
            header=_StringTable.EndDate,
            field_to_csv=lambda c: bulk_datetime_str(c.asset_group.EndDate),
            csv_to_field=lambda c, v: setattr(c.asset_group, 'EndDate', parse_datetime(v))
        ),

Environment:

Let me know if you'd like any further refinements!

xinyuwen2 commented 6 days ago

We only support Year-Month-Day for Asset Group Date. Please check the bulk schema here. (https://learn.microsoft.com/en-us/advertising/bulk-service/asset-group?view=bingads-13#startdate)

Date type definition. (https://learn.microsoft.com/en-us/advertising/campaign-management-service/date?view=bingads-13&tabs=xml)

VadimSaratov commented 6 days ago

@xinyuwen2 then probably something is wrong with the csv file, since I'm getting Start Date 11/18/2024 00:00:00