Piwik API - PDFReports.addReport

I’m trying to use the PDFReports module of the piwik API, specifically PDFReports.addReport. I tried the following in my browser for testing, but it I am receiving an error. Does anyone know if this is a bug or do I have something incorrect?

http://HOST_NAME/piwik/?module=API&method=PDFReports.addReport&idSite=1&description=testAddReport&period=week&hour=0&reportType=email
&reportFormat=pdf&reports=ecommerceOrders&parameters=none&token_auth=TOKEN_AUTH

Hm… I was curious and tried this:

http://server/?module=API&method=PDFReports.addReport&idSite=1&description=testAddReport&period=week&hour=0&reportFormat=pdf&displayFormat=3&reportType=email&reports=ecommerceOrders&parameters=none&token_auth=token

But I keep getting “Missing parameter : displayFormat” error, even though there is displayFormat=3 there.

Does anyone have an example for PDFReports.addReport through the Rest API? I am using Piwik 1.12, but I cannot seem to get this to work.

URL I tried: http://URL/piwik/?module=API&method=PDFReports.addReport&idSite=7&idReport=8&period=day&hour=0&reportType=email&reports=MultiSites_getAll&parameters=test&reportFormat=pdf&description=test1234&format=xml&token_auth=TOKEN

Below is the error message I get.

XML Parsing Error: not well-formed
Location: http://URL/piwik/?module=API&method=PDFReports.addReport&idSite=7&idReport=8&period=day&hour=0&reportType=email&reports=MultiSites_getAll&parameters=test&reportFormat=pdf&description=test1234&format=xml&token_auth=TOKEN
Line Number 4, Column 61: and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).


-------------------------------------------------------------------^

@erodrig9 what is the full error message you get there?

The screenshot and the text I copied into the last post shows everything I get. I’m not getting a full stack trace. I tried it in Firefox, perhaps another browser would show something different?

look at page source, what do you see in the source of the page?

or try a “wget http://url-here

From the page source…

There is an error. Please report the message (Piwik 1.12) and full backtrace in the Piwik forums (please do a Search first as it might have been reported already!).

Warning:
Invalid argument supplied for foreach() in C:\inetpub\wwwroot\piwik\plugins\PDFReports\API.php on line 577

Backtrace -->

#0 Piwik_ErrorHandler(...) called at [C:\inetpub\wwwroot\piwik\plugins\PDFReports\API.php:577]
#1 Piwik_PDFReports_API::validateReportParameters(...) called at [C:\inetpub\wwwroot\piwik\plugins\PDFReports\API.php:94]
#2 Piwik_PDFReports_API->addReport(...) called at [:]
#3 call_user_func_array(...) called at [C:\inetpub\wwwroot\piwik\core\API\Proxy.php:188]
#4 Piwik_API_Proxy->call(...) called at [C:\inetpub\wwwroot\piwik\core\API\Request.php:145]
#5 Piwik_API_Request->process(...) called at [C:\inetpub\wwwroot\piwik\plugins\API\Controller.php:25]
#6 Piwik_API_Controller->index(...) called at [:]
#7 call_user_func_array(...) called at [C:\inetpub\wwwroot\piwik\core\FrontController.php:125]
#8 Piwik_FrontController->dispatch(...) called at [C:\inetpub\wwwroot\piwik\index.php:47]


<?xml version="1.0" encoding="utf-8" ?>

The error occured because I was not passing in parameters as an array. The same goes for reports. Below is an example that will work correctly. Thanks for the help Matt!

http://URL/piwik/?module=API&method=PDFReports.addReport&idSite=7&period=day&hour=0&reportType=email&reportFormat=pdf&description=test1234&reports[0]=MultiSites_getAll&reports[1]=VisitsSummary_get&parameters[displayFormat]=1&parameters[emailMe]=0&token_auth=TOKEN