Re: Status: 400 { responseStatus: { status: 400, code: '9125', severity: 'ERROR',

Soumith
Regular Visitor

Status: 400 { responseStatus: { status: 400, code: '9125', severity: 'ERROR', mess


const express = require('express');
const fs = require('fs');
var https = require('https');
const request = require('request');
const app = express();
const bodyParser = require('body-parser')
var path = require('path');

app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(express.json());
app.use(bodyParser.urlencoded({extended: true}));

var username = '*********';
var password = '**********';
var cert = 'cert.pem';
var key = 'key.pem';

var data ={
"acquirerDetails": {
"bin": 408999,
"settlement": {
"currencyCode": "840"
}
},
"rateProductCode": "A",
"markupRate": "0.07",
"destinationCurrencyCode": "826",
"sourceAmount": "100.55",
"sourceCurrencyCode": "840"
};

app.get('/', (req, res) => {

var options = {
hostname: 'sandbox.api.visa.com',
port: 443,
uri: 'https://sandbox.api.visa.com/forexrates/v2/foreignexchangerates',
method: 'GET',
key: fs.readFileSync(key),
cert: fs.readFileSync(cert),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic ' + Buffer.from(username + ':' + password).toString('base64')
},
json: true
};

options.agent = new https.Agent(options);

request.post(options, (err, res, body) => {
if (err) {
return console.log(err);
}
console.log(`Status: ${res.statusCode}`);
console.log(body);
});
res.send(data);
});

app.listen(3050, function () {
console.log('Example app listening on port 3050.');
})

3 REPLIES 3
I_Doroteo3
Visa Developer Support Specialist

Re: Status: 400 { responseStatus: { status: 400, code: '9125', severity: 'ERROR',

Hi @Soumith

 

Please provide the following information: 

  1. Endpoint  
  2. Request Header 
  3. Request Body 
  4. Response Header (include the x-correlation-id) 
  5. Response Body 

Using SoapUI, you can find the x-correlation-id in the Raw Tab of the response header. 

  

To learn more about common Visa Developer error codes and how to resolve them, please navigate to our Visa Developer Error Codes page here - https://developer.visa.com/pages/visa-developer-error-codes    

  

If you don't find an error code listed here, please refer to the API-specific error codes in its respective documentation pages.

 

Thanks, 

Illana

 

Soumith
Regular Visitor

Re: Status: 400 { responseStatus: { status: 400, code: '9125', severity: 'ERROR',

Status: 401
{ responseStatus:
{ status: 401,
code: '9159',
severity: 'ERROR',
message: 'Token Validation Failed',
info: '' } }

 This is the error code i have been getting

I_Doroteo3
Visa Developer Support Specialist

Re: Status: 400 { responseStatus: { status: 400, code: '9125', severity: 'ERROR',

Hi @Soumith

 

Apologies for the late response- the 401 Token Validation Failed error you're getting will be seen when the x-pay-token sent in the header is invalid. 

A couple of things I'd like you to note while generating the token: 

  1. For starters, please follow the getting started documentation to generate a valid token. https://developer.visa.com/pages/working-with-visa-apis#get-started-overview  
  2. APIkey in the url query param should be the same as the one used to generate xpayToken 
  3. “resourcePath” sent in the xpaytoken has to be as per the documentation (eg: v2/payments?apikey={apikey}). 
  4. Payload sent in the request payload should exactly match along with spaces to the “requestBody” value used in xpaytoken. 

 

Can you please provide the request payload of this API call? It's possible that you're missing a field or have an inaccurate format. I'd like to see screenshot attachments of the error provided, if possible. 

 

Also, could you check to see if you're passing a correct value for URI. For example, make sure it’s defined correctly in the beginning of your code, and use the same value for the URI in the middle of your code. In general, for cases like this (i.e. “helloworld works, but the API XX doesn’t”) I'd like to ask of you, if you could, to please extend your SOAPUI project, and make sure that you can call a particular API from SOAPUI project first. 

 

Thanks, 

Illana