Using RestTemplate with local json file

Background

I am writing a web service that calls external api calls. This api is not yet in production. This way, when I call my web service in my environment, I want to close the responses it returns. Note. This is not a matter of testing the device.

My solution so far

The api call is done with RestTemplate from the lovely Spring folks whose url is stored in application.properties. This allowed me to set different urls for different environments using active profiles. So for example application-dev.properties has a different url. Dev url is a perfect pointer to a json file in resources /.

My question

I cannot get RestTemplate to get the local json file. I am using url:

url = "file://staticJson.json"

      

However, it brings

Object of class [sun.net.www.protocol.ftp.FtpURLConnection] must be an instance of class java.net.HttpURLConnection

      

And now I'm not sure how to proceed, or if it is possible even without extending the RestTemplate.

Any directions to try or solve would be fantastic.

If you need more information, I will do my best to provide it as soon as possible.

+3


source to share





All Articles