Hi,
I’m trying to us chirpstack_api and GetDeviceProfileRequest() to get DeviceProfile protobuf result.
Here is my code.
import grpc
from chirpstack_api import api
# Configuration.
# This must point to the API interface.
server = "localhost:8080"
# The API token (retrieved using the web-interface).
api_token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJjaGlycHN0YWNrIiwiaXNzIjoiY2hpcnBzdGFjayIsInN1YiI6IjcwY2QwN2M4LWQ0MGMtNDRhZi1hMWFiLTc0NDk1MmIxOGMyMSIsInR5cCI6ImtleSJ9.nhaZVaqWAHpUDNIYqNiaA2TMYD9apwBmK-E-gVkb_Sc"
device_profile_id = "63f44437-34bd-44a7-9b5d-25dbb9915521"
if __name__ == "__main__":
# Connect without using TLS.
channel = grpc.insecure_channel(server)
# Device-queue API client.
client = api.DeviceServiceStub(channel)
# Define the API key meta-data.
auth_token = [("authorization", "Bearer %s" % api_token)]
# Construct request.
req = api.GetDeviceProfileRequest()
req.id = device_profile_id
resp = client.Get(req, metadata=auth_token)
# Print the response
print(resp)
And here is the error I’m getting.
Traceback (most recent call last):
File "/home/user/code/DeviceProfile.py", line 30, in <module>
resp = client.Get(req, metadata=auth_token)
File "/home/user/code/.venv/lib/python3.10/site-packages/grpc/_channel.py", line 1181, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/user/code/.venv/lib/python3.10/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Invalid string length"
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"Invalid string length", grpc_status:13, created_time:"2024-06-24T14:22:41.028883953+02:00"}"