Skip to content

sponsored_products Reports BUG #65

Closed

Description

@pengpengker

Describe the bug
1-bug: reports.py-41 kwargs.pop('body') is error,Nofound body in kwargs.
2-bug: client.py-239 Content-type is incorrect, resulting in a return status of 400/422, params should not use the passed data.In general there are multiple errors here

sponsored_products Reports post_report
Not submitting the request with the Content-type will result 422/400 status_code。

To Reproduce
Steps to reproduce the behavior:

  1. call sponsored_products.Reports(credentials=my_credentials, marketplace=Marketplaces.NA, debug=True).post_report(
    recordType="campaigns",
    metrics='impressions',
    reportDate="20220729"
    )

Additional context
I'll submit new code when I'm done, if you're willing to accept。 grateful!

Activity

  1. denisneuf commented on Aug 2, 2022

    @denisneuf
    Owner

    Check the help:

    https://python-amazon-ad-api.readthedocs.io/en/latest/sp/reports.html

    You are using wrong you need to pass your values as a dictionary:

    from ad_api.api.sp.reports import Reports

    file = open("ad_groups.json")
    data = file.read()
    file.close()

    record_type = 'adGroups'

    result = Reports().post_report(
    recordType=record_type,
    body=data
    )

    payload = result.payload
    report_id = payload.get('reportId')

    While the dictionary should look like this:

    {
    "stateFilter": "enabled",
    "reportDate": "20210917",
    "metrics": "campaignName,campaignId,adGroupName,adGroupId,impressions,clicks,attributedConversions30d"
    }

  2. Repository owner locked and limited conversation to collaborators on Aug 2, 2022
  3. converted this issue into a discussion #66 on Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions