google-apigoogle-search-apigoogle-image-search

What cx code must be used in the Programmable Search Engine JSON Api endpoint


According to the rest api documentation of the Programmable Search Engine documentation, the cx parameter must contain the Programmable Search Engine ID. The example uses 017576662512468239146:omuauf_lfve as example. When making our own search engine on https://cse.google.com/, it shows a hexadecimal search engine id, but when using that as the input for the cx parameter we get a bad request error. Using our API key with the example search engine code does work, which makes me believe that we are just entering something invalid into this field. I am unsure however where we are supposed to get the information for this field otherwise. What cx code must be used in the Programmable Search Engine JSON api endpoint?

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "errors": [
      {
        "message": "Request contains an invalid argument.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Form data shown on Programmable Search with private information blanked out


Solution

  • This was likely an issue with Google's api itself not accepting the new format, as the documentation now mentions

    Note: The Search Engine ID (cx) can be of different format (e.g. 8ac1ab64606d234f1)