response is below
'{"responseStatus":{"code":"9501","severity":"ERROR","message":"Invalid input found, please correct the input data","info":"","status":"400"}}'
Am I making any mistake?
Hey @neildave999,
The error code `9501` with the message "Invalid input found, please correct the input data" suggests that there might be an issue with the request payload or how the request is being sent.
Here are some steps to troubleshoot and correct potential issues:
1. Check JSON Formatting:
Ensure that the request payload is properly formatted as JSON. Also, confirm that you're sending the payload as JSON in the `requests.post` call.
2. Content-Type Header:
Make sure the `Content-Type` header is set to `application/json`.
3. Correct Date Format:
Ensure that the date format for `cardExpiryDate` is correct and follows the expected format (`YYYY-MM`).
4. Verify Certificate Paths:
Make sure the paths to your certificate and key files are correct.
5. Verify Payload Fields:
Double-check each field in the payload to ensure they are correct and comply with the API specifications.
6. Ensure Proper Authentication:
Verify that your authentication details (`user` and `pass`) are correct.
Here's the corrected code snippet:
```python
# START
import requests
import json
base_url = "https://sandbox.api.visa.com/pav/v1/cardvalidation"
headers = {
"Content-Type": "application/json",
"Authorization": "Basic YOUR_BASE64_ENCODED_CREDENTIALS"
}
request_body = {
"systemsTraceAuditNumber": "743720",
"cardCvv2Value": "999",
"cardAcceptor": {
"address": {
"country": "USA",
"zipCode": "94404",
"city": "San Francisco",
"state": "CA"
},
"idCode": "111111",
"name": "Visa Inc",
"terminalId": "12345678"
},
"acquirerCountryCode": "840",
"primaryAccountNumber": "4957030420210454",
"acquiringBin": "408999",
"retrievalReferenceNumber": "015221743720",
"cardExpiryDate": "2015-10",
"addressVerificationResults": {
"street": "801 Metro Center Blv",
"postalCode": "94404"
}
}
response = requests.post(
base_url,
headers=headers,
cert=('cert.pem', 'key.pem'),
data=json.dumps(request_body)
)
print(response.text)
# END
```
Make sure to replace `"YOUR_BASE64_ENCODED_CREDENTIALS"` with the correct encoded credentials for basic authentication.