Open dowdot opened 6 years ago
Which message do you get back from the API?
try a
var_dump($result)
to see what the "message" is
The token can't not write to token file. I am trace code, finding an key point
private function curl_authenticate () {
// Get cURL resource
$c_auth = curl_init();
// set default curl options and params
curl_setopt_array($c_auth, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $this->api_url.$this->api_app_id."/user/",
CURLOPT_HEADER => 0,
CURLOPT_VERBOSE => $this->debug,
CURLOPT_TIMEOUT => 30,
CURLOPT_USERAGENT => 'phpipam-api php class',
// ssl
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_HTTPHEADER => array('Authorization: Basic '. base64_encode($this->api_username.":".$this->api_password)),
CURLOPT_POST => true,
)
);
The problem seems use CURLOPT_POST => true
but not setting CURLOPT_POSTFIELDS
,
I am set CURLOPT_POSTFIELDS => 0
The problem no longer occurs. Now, token can write to token file.
This may be a different issue with the curl version.
But dump $result still empty. I try to solveing........
I'm facing also the same HTTP/1.1 400 Bad Request
issue :face_with_head_bandage: with the headers Expect: 100-continue
and Content-Lenght: -1
...but without token file use.
@dowdot catch it, but 0
(that's making a Content-Lenght: 1
and I can see upload completely sent off: 1 out of 1 bytes
then * additional stuff not fine transfer.c:1042: 0 0
etc.) here is a bad/strange request; I'm set CURLOPT_POSTFIELDS => ''
(that's making a Content-Lenght: 0
and now only * additional stuff not fine transfer.c:1042: 0 0
etc.)
Note that we can achive that later result without setting CURLOPT_POSTFIELDS
but adding 'Content-Lenght: 0'
into the array passed to CURLOPT_HTTPHEADER
)
Many many thanks.
I use curl exec is ok , but use api-clients call will return HTTP/1.1 400 Bad Request error... who can help me....
[root@weather IPAM]# curl -X GET http://ipam.xxx.xxx.xxx/api/ipam/user/ --header 'token:h==kas7bR$eX__2TgHKyW0oO'
{"code":200,"success":true,"data":{"expires":"2018-04-14 20:24:39"},"time":0.043}