Hi,
I’m trying to work pagination for list users. But in response header I get Link parameter is empty,
link: ; rel=“self”
link: ; rel=“next”
If I ran the same through Postman, it gives me the correct link.
Below is my code,
$sUrl = 'https://{subdomain}.oktapreview.com/api/v1/users?filter=status%20eq%20%22ACTIVE%22&limit=5';
$request_headers = array();
$request_headers[] = 'Accept: application/json';
$request_headers[] = 'Content-Type: application/json';
$request_headers[] = 'Authorization: SSWS {APIKEY}';
$ch = curl_init($sUrl);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
echo '<pre>';
print_r($header);
echo '</pre>';
echo '<pre>';
print_r(json_decode($body));
echo '</pre>';
Let me know if I’m missing anything.
Thanks!