API with $filter

Hi,

I’m trying to use the an external API that has a $filter parameter.
Link to the API doc: https://www.balena.io/docs/reference/api/overview/

For example, I’m trying to use: https://api.balena-cloud.com/v4/device?$filter=uuid%20eq%20’’

So it works - with just https://api.balena-cloud.com/v4/device

But as soon as I add $filter=uuid%20eq%20’[uuid]’ I’m getting some errors. (malformed URL) back from the API.
Seems like some characters are being replace and might not work right:
device/$filter=uuid%20eq%20%279d0fa03%27’"

There is probably a simple solution to this, but I’d appreciate any help :slight_smile:

Thanks!

Can you post a screenshot of your setting?

I tried different variations, it seems that my issue would have something to do with how the characters are being replaced, specifically, the \ and the ’

This is just a poorly written API doc.
replace the \ after device by ?
https://api.balena-cloud.com/v4/device?$filter=uuid%20eq%20’[UUID]’

1 Like

same result

Raw response for the API
Status code 400
“Malformed url: ‘/resin/device?$filter=uuid%20eq%20%E2%80%999d0fa03%E2%80%99’”

I think thatm my ’ didn’T get paste correctly
https://api.balena-cloud.com/v4/device?$filter=uuid%20eq%20'<UUID>'

Awesome, this works! Thanks a lot :slight_smile:

I have one more question (it’s a little un-related).

When I did the lessons, when selecting an API parameter un the GUI, there wasn’t a “(path)” text next to the parameter name (here uuid) - Why is that?
Screen Shot 2019-12-06 at 10.21.36 PM

This is just to explain that this parameter is included in path (url) part and not set like other parameters or in body/json.

ok, I see. All good then :slight_smile:

Talking about body/json. I’m now trying to get this call into the API Connector

curl -X POST --header “Content-Type:application/json”
–header “Authorization: Bearer ”
–data ‘{ “uuid” : “219135f833a9aabbe6c1e017eb30e29b”, “data” : { “serviceName” : “pihole” } }’
https://api.balena-cloud.com/supervisor/v2/applications/1483865/restart-service

I tried this way, but it doest work. I believe it’s the --data that doesn’t get submitted properly.

Raw response for the API
Status code 400
At least one filter must be specified

Add header Content-Type with value to application/json

perfect, it works!

1 Like

Hello @tim5,

I want to add Balena to Bubble but I have troubles.
I added the API connector but I don’t know which authentification I have to choose and where find my token on Balena.

Could you help me please ?

Hi all,

I am having the same error (URL malformed) but when I’m trying to use the $select parameter for multiple fields. The error occurs when there is a comma involved.

I do have it working in postman:
https://api.balena-cloud.com/v6/device?$filter=is_online%20eq%20false&$select=id,device_name,belongs_to__application,is_online,last_connectivity_event.

The comma’s do translate to url encoded %2C so not sure what’s causing the issue

Any suggestions please.