With the example code, I'm getting the following error...any idea how to fix this?
Tests in error:
postforeignexchangelookupTest(com.visa.developer.sample.foreign_exchange_rates_api.api.FxApiTest): Can not deserialize instance of java.lang.String out of START_OBJECT token(..)
Correct, that is the issue. This is the starter code. Nothing was changed. Just trying to get the starter code to work.
Are you using the FX Rates sample code? Here's the information that we currently have for Java sample code for the Foreign Exchange Rates API. Please see the .zip file attachment.
You can run the test to verify your Visa Developer Portal app credentials allow connectivity to the FX API via running the following class using junit, after decompressing the zip and editing the file with your Visa Developer Portal app credentials.
Edits to lines 57 – 66 would be enough to properly query the foreign exchange rate api:
// Configure HTTP basic authorization: basicAuth
apiClient.setKeystorePath("YOUR KEYSTORE PATH");
apiClient.setKeystorePassword("YOUR KEYSTORE PASSWORD");
apiClient.setPrivateKeyPassword("YOUR PRIVATEKEY PASSWORD");
// To set proxy uncomment the below lines
You only need to uncomment and edit the proxy lines if your current connection requires a proxy to send external queries.
Once your app credentials have been updated, you can use maven “build project” or “mvn clean install” to import the required maven dependencies into your development environment and run the FxApiTest.java file as a junit test. You will be able to see a proper query response, assuming your credentials allow for proper connectivity.