particle-iot / cloud

A place to discuss issues, enhancements, features for: API, Cloud Compiler, Web IDE (Build), Webhooks, Console, and Device Setup
2 stars 0 forks source link

Calling a function with a non-string argument results in 'Unknown Function' error #1

Closed brycekahle closed 4 years ago

brycekahle commented 8 years ago

Expected behavior

{
    "connected": true,
    "id": "<mydeviceid>",
    "last_app": "",
    "return_value": -1
}

Observed behavior

{
    "error": "Function digitalwrite not found",
    "ok": false
}

Steps to reproduce

$ p list mydevice
mydevice [<mydeviceid>] (Photon) is online
  Functions:
    int digitalread(String args)
    int digitalwrite(String args)
    int analogread(String args)
    int analogwrite(String args)

Using httpie

http -v https://api.particle.io/v1/devices/mydevice/digitalwrite "Authorization:Bearer xxx" arg:=1
POST /v1/devices/mydevice/digitalwrite HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: Bearer xxxx
Connection: keep-alive
Content-Length: 10
Content-Type: application/json
Host: api.particle.io
User-Agent: HTTPie/0.9.2

{
    "arg": 1
}

HTTP/1.1 404 Not Found
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 63
Content-Type: application/json; charset=utf-8
Date: Thu, 17 Mar 2016 19:15:34 GMT
Server: nginx

{
    "error": "Function digitalwrite not found",
    "ok": false
}
nickfaughey commented 7 years ago

+1. Just spent a solid 2 hours trying to debug this scenario before realizing I was passing arg as an integer :cry:

timpron commented 6 years ago

+1. spent a day.

markterrill commented 5 years ago

+1 stupid bug. If it receives it as an int, convert the damn thing.

monkbroc commented 4 years ago

Thanks for posting that this was still an open bug. It's now fixed.