Want to pass multiple enum values for PageSpeed Insights API

886 views Asked by At

I'm trying to use PageSpeed Insights API. The API Reference indicates that I can pass multiple category values when calling the API.

I issued the below command. Category values are separated with commas.

curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO'

The API responds with the below JSON.

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
    "errors": [
      {
        "message": "Invalid value at 'category' (TYPE_ENUM), \"ACCESSIBILITY,BEST_PRACTICES,PERFORMANCE,PWA,SEO\"",
        "reason": "invalid"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

I have no idea how I can pass multiple category values. Does anyone know how to do that?

1

There are 1 answers

0
Sham On BEST ANSWER

Pass as seperate parameter rather than comma seperated.

curl 'https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?key=<my key>&url=<my url>&category=ACCESSIBILITY&category=BEST_PRACTICES&category=PERFORMANCE&category=PWA&category=SEO'