Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null. Expected object format is: \r\n

Good day

I will like to get customers credit details in my app after inputer the required parameters through the
form input. After inputing the required values in the form fields and clicking the submit button the
response was json with key but null value.

My Code

// Collection object
        $data = [
            'BVN' => $_POST["customerBVN2"],
            'SessionCode' => $_POST["sessionCode2"],
        ];

        // Credit Registry API url
        $url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Reports/GetData2";

        // Initializes a new cURL session
        $curl = curl_init($url);
        // Set the CURLOPT_RETURNTRANSFER option to true
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        // Set the CURLOPT_POST option to true for POST request
        curl_setopt($curl, CURLOPT_POST, true);
        // Set the request data as JSON using json_encode function
        curl_setopt($curl, CURLOPT_POSTFIELDS,  json_encode($data));
        // Set custom headers for RapidAPI Auth and Content-Type header

        curl_setopt($curl, CURLOPT_HTTPHEADER, [
            'Content-Type: application/json'
          ]);
        
        // Execute cURL request with all previous settings
        $response = curl_exec($curl);
        // Close cURL session
        curl_close($curl);
        echo $response . PHP_EOL;

Error response

{"Success":false,"Errors":["Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null. Expected object format is: \r\n {\r\n \"SessionCode\": \"\",\r\n \"ReportDataRequest\": {\r\n \"BVN\": \"\",\r\n \"AccountOwnerIDs\": \"\",\r\n \"HistoryLengthInMonths\": 84,\r\n \"SectorExclusionIDs\": \"\",\r\n \"IncludeSMARTScore\": false,\r\n \"IncludePDFReport\": false,\r\n \"PDFReportType\": 110,\r\n \"Reason\": \"General credit inquiry\",\r\n \"GetNoMatchReport\": 0\r\n }\r\n}"],"SMARTScores":[],"Accounts":[],"PerformanceSummary":{"Inquiry_Count_12_Months":null,"Count_AccountStatus_Closed":null,"Count_AccountStatus_Delinquent_30_over_60_days":null,"Count_AccountStatus_Derogatory_120_days":null,"Count_AccountStatus_Derogatory_150_days":null,"Count_AccountStatus_Derogatory_Doubtful_180":null,"Count_AccountStatus_Derogatory_Lost_360":null,"Count_AccountStatus_Derogatory_Substandard_90":null,"Count_AccountStatus_Late_less_than_30_days":null,"Count_AccountStatus_Open":null,"Count_AccountStatus_Performing":null,"Count_AccountStatus_Unknown":null,"Count_AccountStatus_Unspecified":null,"Count_AccountStatus_Written_off":null,"Count_LegalStatus_Judgment":null,"Count_LegalStatus_Litigation":null,"Count_LegalStatus_Notice":null,"Count_LegalStatus_Receivership":null,"SelfInquiriesLast12Months":null,"DishonouredChequesLast12Months":null},"AccountSummaries":[],"PDFReport":{"Success":true,"Errors":[],"PDFContent":"","NoMatchPDFContent":"","ReportNo":"","Filename":"","StatusCode":200,"Message":""},"StatusCode":400,"Message":"Invalid request. ReportDataRequest property of the GetDataRequest2 object cannot be null."}

Kindly help

Based on the error response you are getting, it looks like it is expecting a ton of fields that you are not passing along. Based on what you show us, you are only passing along two values when they are expecting a “ReportDataRequest” property that contains more than just BVN. Now if those are the only two that needs to be specified by default, the next issue is that you are simply not building up the $data structure properly to match what it is expecting.

Match up what you are sending in $data to what it is expecting in the service. To do this, print out your JSON $data value and see if it looks like their structure that they are showing in the error message. I assume that is why they are showing you the entire JSON structure in the error message.

:slight_smile:

To be clear, because… that syntax hurts my eyes… what they’re saying the object they expect to receive looks like is:

{
 "SessionCode": "",
 "ReportDataRequest": {
   "BVN": "",
   "AccountOwnerIDs": "",
   "HistoryLengthInMonths": 84,
   "SectorExclusionIDs": "",
   "IncludeSMARTScore": false,
   "IncludePDFReport": false,
   "PDFReportType": 110,
   "Reason": "General credit inquiry",
   "GetNoMatchReport": 0
 }
}

Martyr2 and m_hutley both of you are genius your explanations is on point i got it working thanks man

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.