Unable to update beacon using proximity API

360 Views Asked by At

I managed to successfully register a beacon using the proximity API and can see it when a list the active beacons, but I'm unable to modify the beacon information using the update method.

Here's the successful registration packed

{
  "beaconName": "beacons/3!6564643165626561653336383637373435326335",
  "advertisedId": {
    "type": "EDDYSTONE",
    "id": "ZWRkMWViZWFlMzY4Njc3NDUyYzU="
  },
  "status": "ACTIVE",
  "latLng": {
    "latitude": <removed>,
    "longitude": <removed>
  }
}

and here's the result of the list action GET https://proximitybeacon.googleapis.com/v1beta1/beacons

{
  "beacons": [
    {
      "beaconName": "beacons/3!6564643165626561653336383637373435326335",
      "advertisedId": {
        "type": "EDDYSTONE",
        "id": "ZWRkMWViZWFlMzY4Njc3NDUyYzU="
      },
      "status": "ACTIVE",
      "latLng": {
        "latitude": <removed>,
        "longitude": <removed>
      }
    }
  ]
}

However trying to call a PUT to update gives me a 400 PUT /v1beta1/beacons/3%216564643165626561653336383637373435326335

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"{  \"status\": \"ACTIVE\",  \"latLng\": {    \"latitude\": <removed>,    \"longitude\": <removed>  }}\": Cannot bind query parameter. Field '{  \"status\": \"ACTIVE\",  \"latLng\": {    \"latitude\": -35' could not be found in request message.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "description": "Invalid JSON payload received. Unknown name \"{  \"status\": \"ACTIVE\",  \"latLng\": {    \"latitude\": <removed>,    \"longitude\": <removed>  }}\": Cannot bind query parameter. Field '{  \"status\": \"ACTIVE\",  \"latLng\": {    \"latitude\": -35' could not be found in request message."
          }
        ]
      }
    ]
  }
}

The packet itself is pretty simple

{
  "status":"ACTIVE",
  "latLng": {
    "latitude": <removed>,
    "longitude": <removed>
  },
  "indoorLevel": {
    "name": "4"
  },
  "status": "PORTABLE"
}

Not entirely sure what the cause of the error is and how to resolve.

2

There are 2 best solutions below

1
On

Own question answered. This is the error you get if you forget to pass in a header of "Content-Type: application/json" when using curl.

0
On

Yah, that application/json error message isn't super helpful (¬_¬).

Another problem: There is something wrong with your beaconID. I'm guessing you typed in the "6564643165626561653336383637373435326335" by hand, as it's 40 chars, not 32, which an Eddystone beaconID should be. Even then, the base64 beaconID is also not correct. If you decode it, then you get a 10-byte (20-chars) beaconID.

We've seen some problems in other questions with incorrect beaconIDs.

Make sure that the when you encode them, you're taking the 16-byte BINARY data and base64 encoding that, not the 32-byte hex representation of it.