devicehive / devicehive-java-server

DeviceHive Java Server
http://www.devicehive.com
Apache License 2.0
364 stars 135 forks source link

How to communicate with DeviceHive using curl #544

Open jalin168 opened 3 years ago

jalin168 commented 3 years ago

I refer to deployment-with-docker and use docker-compose up -d to successfully execute DeviceHive. I can log in with dhadmin:dhadmin_#911.

Next, I want to test the ApiInfo API I use the HTTP tool curl to command: curl -v -X GET http://localhost/admin/admin/info The returned result is not as shown by the ApiInfo API, the LOG is as follows:

D:\devicehive-docker-3.5.0\rdbms-image>curl -v -X GET http://localhost/admin/admin/info
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /admin/admin/info HTTP/1.1
> Host: localhost
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.14.0
< Date: Fri, 09 Apr 2021 08:17:50 GMT
< Content-Type: text/html
< Content-Length: 694
< Last-Modified: Mon, 04 Jun 2018 10:54:51 GMT
< Connection: keep-alive
< ETag: "5b151a7b-2b6"
< Accept-Ranges: bytes
<
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Devicehive Admin Panel</title><base href="/admin/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><link href="styles.d6b41c382247cdab36d9.bundle.css" rel="stylesheet"/></head><body><dh-root></dh-root><script type="text/javascript" src="inline.570ed68e3fb93164bffb.bundle.js"></script><script type="text/javascript" src="polyfills.449eac0baaf097d8bdf8.bundle.js"></script><script type="text/javascript" src="scripts.9891c164e0adeb7e15ef.bundle.js"></script><script type="text/javascript" src="main.b140f0fefb939e44372c.bundle.js"></script></body></html>* Connection #0 to host localhost left intact

D:\devicehive-docker-3.5.0\rdbms-image>

Is my communication format wrong? May you provide practical examples? Thank you.

itrambovetskyi commented 3 years ago

curl -X GET --header "Accept: application/json" --header "X-Forwarded-Proto: http" "http://localhost/api/rest/info"