Hello, I'm trying to generate an ad-hoc report via...
# gd-beginners
s
Hello, I'm trying to generate an ad-hoc report via the REST API or Java SDK following the docs here, but I can't manage to put a valid request together. All I'm trying to do here is execute a fairly basic query to get a ticket count per customer in the past 30 days, in the form of a 1 x N grid (where N is the number of customers):
Copy code
SELECT COUNT(Ticket Id) BY Customer WHERE Date (Created At) > THIS - 30
I've created a metric from the above query, but the only kind of report I'm able to generate from it so far is a 1 x 1 grid with the total ticket count in the past 30 days, not the total count per customer which is what I'm after. Below is the payload I'm using to generate the 1 x 1 grid report.
Copy code
{
  "report_req": {
    "definitionContent": {
      "content": {
        "reportDefinition": {
          "content": {
            "filters": [],
            "format": "grid",
            "grid": {
              "rows": [],
              "columns": [
                "metricGroup"
              ],
              "sort": {
                "columns": [],
                "rows": []
              },
              "columnWidths": [],
              "metrics": [
                {
                  "uri": "/gdc/md/pjf7h9zm9zqsfao3l963dx4rnrtnivy4/obj/6275379",
                  "alias": ""
                }
              ]
            }
          },
          "meta": {
            "title": "Untitled report definition",
            "category": "reportDefinition"
          }
        }
      },
      "projectMetadata": "/gdc/md/pjf7h9zm9zqsfao3l963dx4rnrtnivy4"
    }
  }
}
Any tips on how to adjust this payload to get a 1 x N report instead? I've tried adding attribute objects in the
rows
array as suggested in the docs but keep getting back 400 API responses with the message
Cannot create report view.
.
Aha, I might have partly found an answer to my question. I was using the attribute's URI instead of the default display form URI. šŸ¤” Not sure I understand the distinction but at least this time the API spat back something which looks like a 1 x N grid.
m
Hi Sophie, apologies for the delay I’m glad to see you figured it out šŸ™‚ For the Attribute URI - Attributes have one or more display forms that determine how the attribute is presented (e.g., customer name, customer ID). While Display Form URI Defines is how an attribute is displayed in reports.
šŸ‘ 1