Moeez
Moeez

Reputation: 478

Rest API giving NULL in response

I am working with rest API. I am using zoho API's for making calls. Working in yii2 I am trying to call a GET API which gives me some details about my project.

   /* Set the Request Url (without Parameters) here */
    $request_url = 'https://projectsapi.zoho.com/restapi/portal/[PORTALID]/projects/[PROJECTID]/bugs/defaultfields/';
    $ch  = curl_init($request_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('authtoken' => 'key')); // here i am using key but in actual i am putting the real key value
    $curl_response = curl_exec($ch);
    $json = json_decode($curl_response);
    var_dump($json);
    exit();

Accessing it via POSTMAN when I run this call it gives me NULL in response. I have also tried out the way mentioned in the PHP Example here. But it doesn't work out for me as well.

I must be missing something that I don't know.

Any help would be highly appreciated.

Upvotes: 0

Views: 2840

Answers (1)

Code Chef
Code Chef

Reputation: 82

Try checking your headers and make sure you're passing through all the required fields for an example authorization, content type etc.

Upvotes: 1

Related Questions