-
Notifications
You must be signed in to change notification settings - Fork 115
The parameters passed to the API were invalid. Check your inputs! #39
Comments
Hi @ivkean, |
yes, and it's code: |
All required fields in the configuration file are entered? |
@ivkean Have you managed to solve the issue? |
@Bogardo |
I have the same issue. I checked my config file a million times. I always get those kinds of errors. I get the error |
I found the error. The problem is that the Mailgun-PHP package just throws that exception and disregards the data it gets. I edited the file where the error was and just did a
Maybe you could find a way to catch the exception and add the data from the response? Because otherwise with errors like this you just have no clue what went wrong. |
@CupOfTea696 I'm glad you found the problem. And which file did you change to get the error message? |
@CupOfTea696 I see you're already creating a PR on the mailgun/mailgun-php repo. They should probably do something like this: public function responseHandler($responseObj){
$httpResponseCode = $responseObj->getStatusCode();
if($httpResponseCode === 200){
$data = (string) $responseObj->getBody();
$jsonResponseData = json_decode($data, false);
$result = new \stdClass();
// return response data as json if possible, raw if not
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
}
elseif($httpResponseCode == 400){
$response = json_decode((string)$responseObj->getBody(), false);
if (isset($response->message)) {
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS . " " . $response->message);
}
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
}
elseif($httpResponseCode == 401){
throw new InvalidCredentials(EXCEPTION_INVALID_CREDENTIALS);
}
elseif($httpResponseCode == 404){
throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT);
}
else{
throw new GenericHTTPError(EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
}
$result->http_response_code = $httpResponseCode;
return $result;
} |
Yeah, that's pretty close to what I have. I'll create a pull request in a sec. |
@CupOfTea696 There is no need to add this to the |
Trust me, I had a 404 error earlier which I wouldn't have figured out if it wasn't for the response data. It just said the url was wrong, while the actual problem was that I was trying to get() a list that didn't exist (because I thought you could check if the list existed that way but instead it throws this error). |
Hi @Bogardo , I faced same issue ("The parameters passed to the API were invalid. Check your inputs!") when I tried to add a domain that exists already in the same account. I updated responseHandler function to get correct error message. Just want to check whether the code is merged into main repo or not. |
Thanks @CupOfTea696 in the end my message was Please activate your Mailgun account. Check your inbox or log in to your control panel to resend the activation email. How frustrating! |
Hello,
This is my code:
But it show error which is:
The parameters passed to the API were invalid. Check your inputs!
Can you explain ?
Thank you
The text was updated successfully, but these errors were encountered: