Victor Le Pochat
Victor Le Pochat

Reputation: 275

Does the Safe Browsing API v5 support JSON output? (Or, how can I make the Python API client use Protobuf?)

I'm trying to use the Google API Python client to issue requests for the Safe Browsing API v5. It seems like the client is trying to get a JSON response by default, because alt=json is automatically added to the API request URL (example generated by the client: https://safebrowsing.googleapis.com/v5/hashes:search?hashPrefixes=WwuJdQ&key=[]&alt=json)

However, with this addition, I just get an error that the format is not supported:

{
  "error": {
    "code": 400,
    "message": "Unsupported Output Format",
    "status": "INVALID_ARGUMENT"
  }
}

Q1) Does this mean that this API does not support JSON output (yet)? And this despite json being the default output format listed in the API client package's discovery cache (discovery_cache/documents/safebrowsing.v5.json)?

I've also been trying to use the API with Protobuf output, because that does seem to be supported. I got as far as setting the model parameter in the service build method to ProtocolBufferModel, but then I get TypeError: request() missing 1 required positional argument: 'body_value' as an error.

Q2) Since the API does not seem to support JSON yet, how can I get the Google API Python client to work with Protobuf?

(*) I'm aware of the v5alpha1 variant of the API, which has a few more endpoints, but JSON output does not work there either.

Upvotes: 0

Views: 133

Answers (0)

Related Questions