Closed AgentConDier closed 6 years ago
All of the restful API's have test cases that run curl, which you should be able to compare to. eg; https://github.com/servalproject/serval-dna/blob/development/tests/meshmsrestful
You need to send restful parameters using multipart form data. https://github.com/servalproject/serval-dna/blob/34e2e8d4bcb43c882442019769ea6c01c9cdd8a3/doc/REST-API.md#content-type-header
Perhaps using a library like https://www.npmjs.com/package/form-data ?
Ok, I'd say that request looks good, but I get 400 bad request.
POST /restful/meshms/C15AF19927B38717B7A2AF5E16CD00692E3D0C1D4D9EB3A7E46F4ABF722F8567/8C3D3473F6FE865C12457481698ABFEB371B629A4DED6D406DAE0F070AA7EE01/sendmessage HTTP/1.1
Content-Type: multipart/form-data;boundary=WU-J4Vj
Content-Length: 156
Host: 127.0.0.1:4110
Authorization: Basic YWdlbnRjb25kaWVyOmZha2VwYXNzd29yZA==
Connection: close
--WU-J4Vj
Content-Disposition: form-data; name="message"
Content-Type: text/plain; charset=utf-8
This is a testmessage. Hope it arrives! :-P
--WU-J4Vj--
EDIT: Hooray I figured it out. Not really sure what made the difference
POST /restful/meshms/C15AF19927B38717B7A2AF5E16CD00692E3D0C1D4D9EB3A7E46F4ABF722F8567/8C3D3473F6FE865C12457481698ABFEB371B629A4DED6D406DAE0F070AA7EE01/sendmessage HTTP/1.1
content-type: multipart/form-data; boundary=--------------------------820688986682011861789960
Host: 127.0.0.1:4110
Authorization: Basic YWdlbnRjb25kaWVyOmZha2VwYXNzd29yZA==
Content-Length: 248
Connection: close
----------------------------820688986682011861789960
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name="message"
This is a testmessage. Hope it arrives! :-P
----------------------------820688986682011861789960--
OS: ARMBIAN 5.38 stable Ubuntu 16.04.4 LTS 3.10.107-pine64 servald: START-3859-g1930c51+root@localhost-20180404152411 nodejs: v8.9.3
Code: pastebin
Output:
Pretty much the easiest servald-api post request there is, code straight from the nodejs docs Can someone please tell me what I am doing wrong, or give a working example?