Git Product home page Git Product logo

Comments (11)

duylamvo avatar duylamvo commented on June 5, 2024

try with call api from web by copying authorization to the https://api.criteo.com/marketing/swagger/ui/index#!/Statistics/Statistics_GetStats

It is successful.

from criteo-python-marketing-sdk.

tpeyrard avatar tpeyrard commented on June 5, 2024

Hello @dungthuapps, thanks for reporting your issue.

In fact you got the error because you didn't provide the Configuration object to the ApiClient. These are optional, that's why you didn't have to configure them. Hence, you shouldn't get the error => I'll provide a fix.

Meanwhile, to overcome this problem and get the "automatic token refresh" feature, you can follow the example:

configuration = Configuration()
configuration.username = sys.argv[1]
configuration.password = sys.argv[2]
# Enable/Disable debug httplib and criteo_marketing packages
# logging.basicConfig(level=logging.DEBUG)
# configuration.debug = True
client = criteo_marketing.ApiClient(configuration)
.

from criteo-python-marketing-sdk.

duylamvo avatar duylamvo commented on June 5, 2024

Hi @tpeyrard,
It is good to use configuration. I dont see error.
But when try with get_stats, the result is none. When trying with https://api.criteo.com/marketing/swagger/ui/index#!/Statistics/Statistics_GetStats , result is a link of csv file

from criteo-python-marketing-sdk.

duylamvo avatar duylamvo commented on June 5, 2024

my code:

api_instance = criteo_marketing.StatisticsApi(client)
stats_query_message_ex = criteo_marketing.StatsQueryMessageEx(
            report_type="CampaignPerformance"
            , dimensions=["CampaignId"]
            , metrics=["Clicks"]
            , start_date="2019-01-01"
            , end_date="2019-01-09"
            , format="Csv")
stats_response = api_instance.get_stats(token, stats_query_message_ex)
pprint(stats_response)

result: None

from criteo-python-marketing-sdk.

duylamvo avatar duylamvo commented on June 5, 2024

when using debug, I found the data was returned. but dont know how to get this data

DEBUG:urllib3.connectionpool:https://api.criteo.com:443 "POST /marketing/v1/statistics HTTP/1.1" 200 136
DEBUG:criteo_marketing.rest:response body: 
Advertiser Name;Campaign ID;Campaign Name;Currency;Clicks
Adviser_1;222;abc;EUR;111
Adviser_1;222;abc;EUR;111

from criteo-python-marketing-sdk.

duylamvo avatar duylamvo commented on June 5, 2024

Turn out, it sets response_type = None, (even with response_data != None)
(in statistics_api.py, method get_stats_with_http_info(.)
return self.api_client.call_api( '/v1/statistics', 'POST', ... response_type=None, # noqa: E501 ...)

from criteo-python-marketing-sdk.

tpeyrard avatar tpeyrard commented on June 5, 2024

Hello,
I'll have a look why this endpoints forces OpenAPI generator to set the response_type to None.

from criteo-python-marketing-sdk.

tpeyrard avatar tpeyrard commented on June 5, 2024

Hi @dungthuapps,

patch is on its way. I hope to deploy it today or next Monday.

from criteo-python-marketing-sdk.

tpeyrard avatar tpeyrard commented on June 5, 2024

@dungthuapps, changes have been rollout.

Please tell me if it works on your side. I added an example to save the content to a file:

stats_api = cm.StatisticsApi(client)
stats_query_message = cm.StatsQueryMessageEx(
report_type="CampaignPerformance",
dimensions=["CampaignId"],
metrics=["Clicks"],
start_date="2019-01-01",
end_date="2019-01-31",
format="Csv")
# Use the method with 'with_http_info' if you want to retrieve the filename
# Otherwise, you can directly call the get_stats method and write the return value to a file
[response_content, http_code, response_headers] = stats_api.get_stats_with_http_info(token, stats_query_message)
if 200 == http_code:
content_disposition = response_headers["Content-Disposition"]
if content_disposition:
filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1)
# $> file Extract_20190101_20190131.csv
# Extract_20190101_20190131.csv: UTF-8 Unicode (with BOM) text, with CRLF line terminators
with open(filename, "w+") as f:
f.write(response_content)

from criteo-python-marketing-sdk.

duylamvo avatar duylamvo commented on June 5, 2024

hi, updated new version. it works from my side.
both the code above and get_stats(.)

thanks

from criteo-python-marketing-sdk.

rmadisonhaynie avatar rmadisonhaynie commented on June 5, 2024

Hello
what is the metric name to get the spend of the campaign. I tried cost,spend, campaignCost to no avail. The swagger documentation also doesn't have a place that lists the available metrics to query

Hello @negm could you please ask your question in a new issue, thank you.

from criteo-python-marketing-sdk.

Related Issues (7)

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.