I’m trying to set up an API
GET method request using an external url. To do this, I need to set a username and password. The goal is to get the data and display it on my page.
Since a few days I’m trying to find documentation (as i’m not confident with this), but unfortunately I haven’t found anything that match. Can anybody explain or provide some good documentation or script example what is needed to setup it?
Something like that ?
That looks ok, does it work for u?
Do you have any information/documentation on the API you want to use? Usually using cfhttp is like doing curl, but you’ll have to translate all parameters needed by the API such as headers/forms/etc. to work with cfhttp. Take a look at this post just to check what I mean:
hi Zac thx for your reply. Unfortunately, it doesn’t work.
Unknown host: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Unable to determine MIME type of file.
username and password is correct because i tested in </> Rested Client of Firefox.
Thx for your support and reply
Hi Andreas, thank you for your reply. I have the response, structure and parameters.
In your post the they are using
method post and i want to request data, so i should use get, correct?
I should get the following information… of course with the right endpoint, username and password
Just like @psarin already mentioned, it seems a certifcate evaluation issue.
I should of asked my standard question first, which version of Lucee and Java are you using?
@Retooo, I’ve analyzed your issue. Could you please check with this link too. I hope, this will help to you.
Hi I’m using Lucee 184.108.40.206
and Java 1.7.0_131 (Oracle Corporation) 64bit
Thank you i will try your suggestion and come back to you asap
That’s a really, really old software stack, does it work with the latest release?
Hi Zac_Spitzer, if i use another url with no username and password it works:
<cfhttp url="https://reqres.in/api/users/2" method="GET" result="remoteCallResult" >
<cfhttpparam type="header" name="accept-encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
Unless the other URL is using a similar ssl certificate, it’s not a useful comparison
If you update your java-version it should work.
Which you NEED to do. Upgrade to Java 8, preferably an OpenJDK build ( unless you’re paying Oracle for support )
Java 7 is way old. If you MUST run Java 7, you’re going to have issues with TLS1.2 being the minimum real soon, and your cacerts are old - both the one packaged with the old version of Lucee, and the one packaged with the Java 7 JVM.
I generated this one from Ubuntu Bionic as of today. Replace the one you have in your lucee folders with this one.
cacerts (152.6 KB)