Foreign Exchange Rates API

muraliisu
Helper

Foreign Exchange Rates API

Hi,

I've downloaded Foriegn exchange Api source code.

And I've created p12 file. 

When i'm sending request through SOAPUI, It's working properly.

But in the source code, it's working, It's Receiving response excepton as 'Bad Request'.

Can you please help me to solve this.

8 REPLIES 8
jvenkata
Community Moderator

Re: Foreign Exchange Rates API

Hi,

 

Thanks for your inquiry. Can you please share the following to debug further ?

 

1. Are you using the sample code from VDP Dashboard --> Sample Code section ?

2. Endpoint

3. Request Header & Body

4. Response Header - Include x-correlation-id

5. Response Body

 

Thanks,

Jai

muraliisu
Helper

Re: Foreign Exchange Rates API

Hi,

Yes, I've downloaded from  VDP Dashboard --> Sample Code section.

Endpoint, Request Header & Body, Response Header - Include x-correlation-id, Response Body

 

Request

POST https://sandbox.api.visa.com/forexrates/v1/foreignexchangerates HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/json
Authorization: Basic RFlIQ0kzQzlSR1E0RzlVTENQSzMyMXotOEYxb1A5OFE4UTAzb2xCRkRuR2Q1Y1E5dzpyOUlCazBCcEpyR2lrOXBQOUpyNk9HY3BCbUVYYzFw
Content-Length: 433
Host: sandbox.api.visa.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_181)
Expect: 100-continue

{"acquirerCountryCode": "840","acquiringBin": "408999","cardAcceptor": {"address": {"city": "San Francisco","country": "USA","county": "San Mateo","state": "CA","zipCode": "94404"},"idCode": "ABCD1234ABCD123","name": "ABCD","terminalId": "ABCD1234"},"destinationCurrencyCode": "826","markUpRate": "1","retrievalReferenceNumber": "201010101031","sourceAmount": "100.00","sourceCurrencyCode": "840","systemsTraceAuditNumber": "350421"}.

 

 

Same Reqeust when i sent from PostMAN/SOAPUI, It's working properly.

When I use same Certifcates,UserName, Password From Sample Code, t's Getting 'Bad Request'.

muraliisu
Helper

Re: Foreign Exchange Rates API

Response is

{X-SERVED-BY: l55c004
X-CORRELATION-ID: 1553231618_739_101_l55c004_VDP_ARM
X-APP-STATUS: 400
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=2592000;includeSubdomains
Pragma: no-cache
X-Cnection: close,close
Connection: close
Content-Length: 224
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/xml;charset=UTF-8
Date: Fri, 22 Mar 2019 05:13:38 GMT
Expires: -1
Server: Apache

}

jvenkata
Community Moderator

Re: Foreign Exchange Rates API

Hi,

 

This error ususally happens when Client certificates not sent along with the request because of networking issues on the client side. If the same .p12 is working fine with SOAP UI, then we need to look at the code on how it is being called from the code. Can you please share your test class so we can take a look at the code on the .p12 is being refernced. If you have difficulty posting the code here, please share it to developer@visa.com, so we can get back to you accordingly.

 

Thanks,

Jai

muraliisu
Helper

Re: Foreign Exchange Rates API

Hi Jai,

Thanks for your response.

I'm sending the client certificates from SOAP UI, it's worked there.

When I;m sending the same certificates from Code, it's not working.

I'll share the code by E-Mail, kindly look.

Thank you in advance.

 

Regards

Murali

 

jvenkata
Community Moderator

Re: Foreign Exchange Rates API

Hi Murali,

 

Since you are using C#,  please try rebuilding key certificate bundle for .NET developers. Note there is no -certfile attribute in the below command.

 

Sample command below

$ openssl pkcs12 -export -out myProject_keyAndCertBundle.p12 -inkey key_63973e0f-6bae-4ae0-98b9-5f6tg153ce2e.pem -in cert.pem

 

Thanks,

Jai

muraliisu
Helper

Re: Foreign Exchange Rates API

Hi Jai,

Thank you for response.

Unfortunately, this solution is also not working with C# code.

        I've generated p12 certificate by using openstool with follwing command.

       openssl pkcs12 -export -out myProject_keyAndCertBundle.p12 -inkey key.pem -in cert.pem

        I'm sending myProject_keyAndCertBundle.p12 certificate as following.

        X509Certificate2 certificate = new X509Certificate2(certificatePath, certificatePassword);
        ServicePointManager.Expect100Continue = true;
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        request.ClientCertificates.Add(certificate);
        request.PreAuthenticate = true;

        But It's returning same reponse as Bad Request-400.

Thanks,

Jai

anturaj
Dabbler

Re: Foreign Exchange Rates API

Hello,

I tried using the API on my website  and getting  issues like My users are saying that they are having issue while changing currency or paying via Card. Any solution for that?