Good day
I tried getting a json response using the below written code but instead it returned the following error message
{“Message”:“The request entity’s media type ‘multipart/form-data’ is not supported for this resource.”}
see the code below
$mydata = array(
'number1' => $_POST["customerNUM1"],
'number2' => $_POST["sessionNUM1"],
);
$headers = array(
'Content-Type' => 'application/json'
);
$ch = curl_init($url);
// curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar);
// curl_setopt($ch,CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch,CURLOPT_MAXREDIRS,0);
curl_setopt($ch,CURLOPT_TIMEOUT,30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$err = curl_error($ch);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Kindly help
We need to know what the service is awaiting…. Otherwise we cannot help
it is awaiting the following url
$url = “https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Customers/FindByBVN2 ”;
Edited code
$mydata = array(
'number1' => $_POST["customerNUM1"],
'number2' => $_POST["sessionNUM1"],
);
$headers = array(
'Content-Type' => 'application/json'
);
$url = "https://api2.creditregistry.com/nigeria/AutoCred/v7.Test/api/Customers/FindByBVN2";
$ch = curl_init($url);
// curl_setopt($ch,CURLOPT_COOKIEJAR, $this->cookie_jar);
// curl_setopt($ch,CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, False);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, False);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch,CURLOPT_MAXREDIRS,0);
curl_setopt($ch,CURLOPT_TIMEOUT,30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $mydata);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$err = curl_error($ch);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
I cannot find any manual for this API. Where is the documentation?
I am sorry, I cannot find any document what parameters are expected. Where is defined what customerNUM1 and sessionNUM1 should contain?
What I guess is, that the parameters should be in JSON format and I am pretty sure that an array is not the correct format. But as long as I don’t find a working sample i do not know
Thallius, thank you i will rewrite the code and repost
Did you try to request something with Postman?
system
Closed
December 18, 2021, 9:50pm
9
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.