GoogleAPI doesn't accept Python boolean value

114 views Asked by At

We are interacting with the public TTN API (based on Google API) and I am trying to deliver a boolean value. This would be my data package:

ns_data = {
    "end_device": {
        "ids": {
            "dev_eui": str(self.device.internal_id),
            "join_eui": str(self.device.app_eui)
        },
        "supports_join": True
    }, "field_mask": {
        "paths": [
            "supports_join"
        ]
}}
request("PUT", f"/api/v3/ns/applications/{str(self.device.company.uuid)}/devices/{self.device.uuid}", json=ns_data, headers={"Content-Type": "application/json", "Authorization": "Bearer " + API_KEY})

The response is {"code":3,"message":"error:pkg/networkserver:field_value (invalid value of field 'supports_join')","details":[{"@type":"type.googleapis.com/ttn.lorawan.v3.ErrorDetails","namespace":"pkg/networkserver","name":"field_value","message_format":"invalid value of field {field}","attributes":{"field":"supports_join"}.

When changing the field to string and providing 'true' here the error changes slightly to {"code":3,"message":"ReadBool: expect t or f, but found \\", error found in #10 byte of ...|s_join\\": \\"true\\"}, \\"f (...) which is even more strange. I tried providing it as a dict as well, but the API definition states that it should be bool.

0

There are 0 answers