I do request from postman. Hello world works fine but https://sandbox.api.visa.com/aliasdirectory/v1/getAliasMetadata
giving error.
request
curl --location 'https://sandbox.api.visa.com/aliasdirectory/v1/getAliasMetadata' \
--header 'keyId: cec32378-041a-4b45-8a44-63cec766f6d1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic S0E3RjJZRkRTWEU2UjhLOFZaS0YyMXpqSnVrZTdLTWV3aTcxYjdyS3Y4VFlPdnhDRTozaGx1b1Y3NW9jcDl3QTlCQWl0SFpaUWN0NDg=' \
--data '{
"aliases": [
"19002387857"
]
}'
response
Hi @Super11, Thank you for reaching out. An agent will get back to you as soon as possible. Until then, if any community member knows a solution, feel free to reply in this thread.
Hey @Super11,
Based on the error message you are encountering, it appears that there is an issue with the token validation for your API request. Below are some common steps and checks you can follow to troubleshoot and resolve this issue:
Troubleshooting Steps
1. Verify API Credentials:
Ensure that the `keyId` and `Authorization` headers contain the correct credentials. Double-check that these values are correct and have not expired or been revoked.
2. Base64 Encoding:
Make sure that the `Authorization` header is correctly encoded in Base64. It should be in the format `Basic {Base64EncodedString}`, where the Base64 encoded string is the combination of your `username:password`.
3. Check API Key Permissions:
Confirm that your API key has the necessary permissions to access the Alias Directory API. You can verify this in the Visa Developer Portal under your project settings.
4. Environment Configuration:
Ensure you are using the correct environment (sandbox) and that your API key and credentials are configured for the sandbox environment.
5. Endpoint URL:
Verify that the endpoint URL is correct and matches the API documentation.
6. JSON Payload:
Confirm that the JSON payload is correctly formatted and valid. In your example, it looks correct, but double-check for any hidden characters or formatting issues.
Example Request
Below is an example cURL command to help you verify your request:
```bash
# START
curl --location 'https://sandbox.api.visa.com/aliasdirectory/v1/getAliasMetadata' \
--header 'keyId: cec32378-041a-4b45-8a44-63cec766f6d1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic S0E3RjJZRkRTWEU2UjhLOFZaS0YyMXpqSnVrZTdLTWV3aTcxYjdyS3Y4VFlPdnhDRTozaGx1b1Y3NW9jcDl3QTlCQWl0SFpaUWN0NDg=' \
--data-raw '{
"aliases": [
"19002387857"
]
}'
# END
```
Common Issues and Solutions
1. 401 Unauthorized - Token Validation Failed:
- Double-check the `Authorization` header for correct Base64 encoding.
- Ensure that the API key (`keyId`) and secret are correctly configured and active.
2. Check Visa Developer Portal Logs:
- Log in to the Visa Developer Portal.
- Navigate to your project and check the transaction logs for more detailed error information.
3. Regenerate API Key and Secret:
- If you suspect the credentials might be incorrect or compromised, regenerate the API key and secret and update your request with the new credentials.
Final Steps
If you have followed all the steps and continue to face issues, consider reaching out to Visa Developer support for further assistance. Provide them with your request details, including the error message and any relevant logs.
Summary
By ensuring that your credentials are correct, properly encoded, and that your API key has the necessary permissions, you should be able to resolve the `401 Unauthorized` error.