Leg
March 18, 2023, 11:33pm
1
I’m calling procedure on device using API and this seems doesn’t work. The same parameters works perfectly from web console:
curl -X 'POST' \
'https://api.golioth.io/v1/projects/test_1/devices/<REDACTED>/rpc' \
-H 'accept: application/json' \
-H 'x-api-key: <REDACTED>' \
-H 'Content-Type: application/json' \
-d '{
"method": "number",
"params": [
{ "process_code_push" : 100 }
],
"timeout": 4
}'
Response from Open API:
Code 200
Response body
{
"statusCode": 14,
"detail": null
}
Could you please help me figure our what is wrong? Does json structure in request correct? What statusCode: 14 means?
Thank you
dylan
March 23, 2023, 6:48pm
2
Hi Leg,
Can you share which Golioth SDK and version you are using?
Thanks,
Dylan
Leg
March 23, 2023, 6:54pm
3
Sure. Version: 0.6.0.
Just want to add that calls from web console to the same client and callbacks work fine
dylan
March 23, 2023, 7:11pm
4
Perfect thanks that is helpful information for us track this one down! To confirm are you using Zephyr and our Zephyr SDK ?
Leg
March 23, 2023, 7:15pm
5
Nope. We’re using Golioth Firmware SDK on Espressif ESP-IDF with ESP32-S3
dylan
March 23, 2023, 7:34pm
6
Hey Leg,
That make sense! In your curl command here it looks like you’re passing number
as the method name. I expect however the name of your function in your firmware is actually process_code_push
. Is that correct?
If so your CURL command should look more like this:
curl -X 'POST' \
'https://api.golioth.io/v1/projects/test_1/devices/<REDACTED>/rpc' \
-H 'accept: application/json' \
-H 'x-api-key: <REDACTED>' \
-H 'Content-Type: application/json' \
-d '{
"method": "process_code_push",
"params": [
{100}
],
"timeout": 4
}'
The statusCode 14 is coming from the device itself indicating that the RPC method was unavailable (we can improve our documentation here).
I can see in our OpenAPI Docs that we use the example value “string” for the method name which is confusing. Let us know if that works!
Leg
March 23, 2023, 9:02pm
7
Hi Dylan,
Thank you! It works now!
I just made small adjustment in your CURL command as our callback expects number:
curl -X 'POST' \
'https://api.golioth.io/v1/projects/test_1/devices/<REDACTED>/rpc' \
-H 'accept: application/json' \
-H 'x-api-key: <REDACTED>' \
-H 'Content-Type: application/json' \
-d '{
"method": "process_code_push",
"params": [
100
],
"timeout": 4
}'
Glad that worked! For future posts (and for others reading this in the future) be sure not to share API keys in forum posts. I removed that and your device ID from your response.