Control Web Panel
WebPanel => CentOS-WebPanel Bugs => Topic started by: nborromeo on April 25, 2019, 10:16:00 PM
-
Hi, I haven't had any success in consuming data and sending payload via the API.
Here's my php test code:
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$data = array("key" => "xxxx","action"=>'list');
$url = "https://my_host:2304/v1/account";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 1 );
curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 2 );
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
var_dump($response);
var_dump(curl_getinfo($ch));
var_dump(curl_error($ch));
curl_close($ch);
Here's the php result:
vonjour@devel2019:~/Desktop/vonjour.Docker$ php -f test.php
/home/vonjour/Desktop/vonjour.Docker/test.php:24:
string(237) "HTTP/1.1 200 OK
Server: cwpsrv
Date: Thu, 25 Apr 2019 21:53:14 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/7.0.32
{"status":"Error","msj":"error in key","format":"JSON"}"
/home/vonjour/Desktop/vonjour.Docker/test.php:25:
array(26) {
'url' =>
string(38) "https://my_host:2304/v1/account"
'content_type' =>
string(16) "application/json"
'http_code' =>
int(200)
'header_size' =>
int(182)
'request_size' =>
int(69)
'filetime' =>
int(-1)
'ssl_verify_result' =>
int(20)
'redirect_count' =>
int(0)
'total_time' =>
double(1.40952)
'namelookup_time' =>
double(0.257413)
'connect_time' =>
double(0.529659)
'pretransfer_time' =>
double(1.100879)
'size_upload' =>
double(0)
'size_download' =>
double(55)
'speed_download' =>
double(39)
'speed_upload' =>
double(0)
'download_content_length' =>
double(-1)
'upload_content_length' =>
double(-1)
'starttransfer_time' =>
double(1.409498)
'redirect_time' =>
double(0)
'redirect_url' =>
string(0) ""
'primary_ip' =>
string(15) "192.6445.xxx.xxx"
'certinfo' =>
array(0) {
}
'primary_port' =>
int(2304)
'local_ip' =>
string(11) "192.168.0.9"
'local_port' =>
int(45576)
}
/home/vonjour/Desktop/CoreDev.Docker/test.php:26:
string(0) ""
Here's an test I've found from other threads:
nborromeo@cent ~$ curl -k "https://xxx.xxx.xxx.xxx:2304/v1/account" -X POST -data "key=IEmzLcOF4Hsozt9bTopbrhQ19nPt6ZuM3BA4pjK49nzVf&action=list"
{"status":"Error","msj":"error in key","format":"JSON"}curl: (6) Could not resolve host: key=IEmzLcOF4Hsozt9bTopbrhQ19nPt6ZuM3BA4pjK49nzVf&action=list; Unknown error
-
looks like you have dns resolving issues on your server, you need to check /etc/resolv.conf with your server provider or try to use google dns
nameserver 8.8.8.8
-
The message is clear
{"status": "Error", "msj": "error in key"
Error in the key, go to the api admin and confirm that yu api key is the same one that you are using, you can also validate that the IP or the answer type are the same as json
-
The message is clear
{"status": "Error", "msj": "error in key"
Error in the key, go to the api admin and confirm that yu api key is the same one that you are using, you can also validate that the IP or the answer type are the same as json
I'm waiting for you to say this actually. I've got the same API key listing on the API manager, and on the same IP address.
-
The message is clear
{"status": "Error", "msj": "error in key"
Error in the key, go to the api admin and confirm that yu api key is the same one that you are using, you can also validate that the IP or the answer type are the same as json
I tried about 5 machines got the same error.
It's not a Firewall issue, I added it already.
-
I would like to help you solve this problem, I could try placing% instead of the server ip in the apikey
-
The message is clear
{"status": "Error", "msj": "error in key"
Error in the key, go to the api admin and confirm that yu api key is the same one that you are using, you can also validate that the IP or the answer type are the same as json
I tried about 5 machines got the same error.
It's not a Firewall issue, I added it already.
added the %, *, 0.0.0.0 and a blank IP origin just to try everything. got the same Error in key message.
-
funny I have this list already
(https://i.imgur.com/3V5K0Fh.png)
-
Anyone from the CWP team? is CWP out of business?
-
Did you already tried this?:
curl -k "https://xxx.xxx.xxx.xxx:2304/v1/account" -X POST --data "key=IEmzLcOF4Hsozt9bTopbrhQ19nPt6ZuM3BA4pjK49nzVf" --data "action=list"
(with separated arguments, and '--data', not '-data')
Regards,
Netino
-
Did you already tried this?:
curl -k "https://xxx.xxx.xxx.xxx:2304/v1/account" -X POST --data "key=IEmzLcOF4Hsozt9bTopbrhQ19nPt6ZuM3BA4pjK49nzVf" --data "action=list"
(with separated arguments, and '--data', not '-data')
Hi Netino, good news! it works! I'll test some more on the other endpoints and action types. Thank you! I never thought of separating the POST data would solve it.
Best,
Regards,
Netino
-
Hi Netino, just want to let you know that it worked pretty well on other endpoints and different actions too! thank you!
Best
-
Hello
Apparently you have a problem with the api key!