Cfhttp get methode setup

Hi guys,

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 ?

<cfhttp
  url="https://xxxxxxxxxxxxxxx"      
  method="get"
  username="*************3"
  password="*************"
  useragent="#CGI.http_user_agent#"
  result="objGet">
<cfoutput>#objGet.FileContent#</cfoutput>

Thank you

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.

I get:
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

Check out java - "PKIX path building failed" and "unable to find valid certification path to requested target" - Stack Overflow

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?

1 Like

@Retooo, I’ve analyzed your issue. Could you please check with this link too. I hope, this will help to you.
https://support.cloudbees.com/hc/en-us/articles/217078498-PKIX-path-building-failed-error-message

Hi I’m using Lucee 5.1.2.24
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:
see below

 <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" />
 </cfhttp>
 
 <cfdump var="#remoteCallResult#">

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.

1 Like

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)

More Context:

See also
https://luceeserver.atlassian.net/browse/LDEV-917?focusedCommentId=41066&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

1 Like