Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Param ordering specificaton using JSON is not correct in cylon-api-http(CPPP-IO base HTTP cylon API) #6

Open
kendemu opened this issue Feb 6, 2017 · 0 comments

Comments

@kendemu
Copy link

kendemu commented Feb 6, 2017

Hello,
I'm making a drone app controlling from HTTP REST using the cylon-api-http module which describes that the API specification is documented in the CPPP-IO.
However, when I wrote this Ajax POST code in JavaScript seeing the CPPP-IO specification, it doesn't work.

var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3001/api/robots/Scratch4D/devices/drone/commands/front", false);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send({"a": speed});

However, when I did this HTTP Request from cURL, it works.

curl localhost:3001/api/robots/Scratch4D/devices/drone/commands/front -d params=1.0

When I looked the HTTP Header of this request, I was very surprised.

0000: POST /api/robots/Scratch4D/devices/drone/commands/front HTTP/1.1
0042: Host: localhost:3001
0058: User-Agent: curl/7.47.0
0071: Accept: */*
007e: Content-Length: 10
0092: Content-Type: application/x-www-form-urlencoded
00c3: 
=> Send data, 10 bytes (0xa)
0000: params=1.0
== Info: upload completely sent off: 10 out of 10 bytes
<= Recv header, 17 bytes (0x11)

This request doesn't use any JSON. The content type is not application/json. And the body is not JSON object.

From this information, I implemented my app with this code. (working code)

var xhr = new XMLHttpRequest();
xhr.open("POST", "http://localhost:3001/api/robots/Scratch4D/devices/drone/commands/front", false);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send("params="+speed.toString());

Is your specification document correct? The JSON format doesn't works.

@kendemu kendemu changed the title Param ordering specificaton is not correct in cylon-api-http(CPPP-IO specific HTTP cylon API) Param ordering specificaton is not correct in cylon-api-http(CPPP-IO base HTTP cylon API) Feb 6, 2017
@kendemu kendemu changed the title Param ordering specificaton is not correct in cylon-api-http(CPPP-IO base HTTP cylon API) Param ordering specificaton using JSON is not correct in cylon-api-http(CPPP-IO base HTTP cylon API) Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant