Facing an issue in helloworld api only
{
"responseStatus": {
"status": 401,
"code": "9159",
"severity": "ERROR",
"message": "Token Validation Failed",
"info": ""
}
}
Here i am trying to create a x-pay token
Hi @saisandeep, Thank you for reaching out. One of our agents will look into this and get back to you soon. If any community member knows a solution, please feel free to reply to this thread.
Hi, No Agent is assigned. Its been almost two weeks now and none of the support team has reached out to us.
@saisandeepbcbsfl wrote:Facing an issue in helloworld api only
{
"responseStatus": {
"status": 401,
"code": "9159",
"severity": "ERROR",
"message": "Token Validation Failed",
"info": ""
}
}
Here i am trying to create a x-pay tokenvar resourcePath = 'helloworld';var queryParams = 'apiKey=QM6BVPJH6XNA7RMZGLJG21iNon2ZUrYEA5CDL3sTmKb_-7Xzk';var sharedSecret = 'UJ8qGPUcz{H2gL1YPUMnaXUIJaMbVp2asi0U6w$3';var postBody = '';var timestamp = Math.floor(Date.now() / 1000);var preHashString = timestamp + resourcePath + queryParams + postBody;var hashString = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(preHashString, sharedSecret));var xPayToken = 'xv2:' + timestamp + ':' + hashString;postman.setEnvironmentVariable('x-pay-token', xPayToken);
Please let me know the issue
Hello, @saisandeep
Please see below information and follow.,
// Resource path for the API endpoint
var resourcePath = 'helloworld';
// Query parameters with the API key
var queryParams = 'apiKey=QM6BVPJH6XNA7RMZGLJG21iNon2ZUrYEA5CDL3sTmKb_-7Xzk';
// Shared secret provided by the API service
var sharedSecret = 'UJ8qGPUcz{H2gL1YPUMnaXUIJaMbVp2asi0U6w$3';
// Post body for the API call (if any)
var postBody = '';
// Current timestamp in seconds
var timestamp = Math.floor(Date.now() / 1000);
// Concatenating the required elements for hashing
var preHashString = timestamp + resourcePath + queryParams + postBody;
// Generating the HMAC SHA256 hash of the pre-hash string
var hashString = CryptoJS.enc.Hex.stringify(CryptoJS.HmacSHA256(preHashString, sharedSecret));
// Creating the x-pay token
var xPayToken = 'xv2:' + timestamp + ':' + hashString;
// Setting the x-pay token in the environment variable
postman.setEnvironmentVariable('x-pay-token', xPayToken);
I hope my suggestion is helpful for you.
Best Regard,
diana658
Still i am getting the same error.
Hi @diana658,
Please visit the Visa Developer Error Codes page for cause/resolution.