tim5
December 6, 2019, 3:41pm
1
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
Thanks!
Jici
December 6, 2019, 4:12pm
2
Can you post a screenshot of your setting?
tim5
December 6, 2019, 6:33pm
4
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 ’
Jici
December 6, 2019, 7:10pm
5
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
tim5
December 7, 2019, 1:14am
6
same result
Raw response for the API
Status code 400
“Malformed url: ‘/resin/device?$filter=uuid%20eq%20%E2%80%999d0fa03%E2%80%99’”
Jici
December 7, 2019, 2:36am
7
I think thatm my ’ didn’T get paste correctly
https://api.balena-cloud.com/v4/device?$filter=uuid%20eq%20'<UUID>'
tim5
December 7, 2019, 3:10am
8
Awesome, this works! Thanks a lot
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?
Jici
December 7, 2019, 3:56am
9
This is just to explain that this parameter is included in path (url) part and not set like other parameters or in body/json.
tim5
December 7, 2019, 5:18am
10
ok, I see. All good then
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
Jici
December 7, 2019, 5:54pm
11
Add header Content-Type with value to application/json
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 ?