Need help converting Curl to CF - Jira Cloud REST API

Hello,

I am successfully able to execute the following curl request to get issues from Jira Cloud via API call.

curl --request GET
–url ‘https://hgdata.atlassian.net/rest/api/2/search?jql=project=HG&fields=key,summary,description&maxResults=100
–user ‘< email >:< token >’
–header ‘Accept: application/json’

I am trying to convert this to run in CF (see code below). The problem is I don’t know how to code the --user info. If anyone can give me some guidance on this, it would be greatly appreciated.

< cfhttp
method=“get”
url=“https://hgdata.atlassian.net/rest/api/2/search?jql=project=HG&fields=key,summary,description&maxResults=100”>

< cfhttp
method=“get”
username="SOMETHINGUSERNAMEY"
password="SOMETHINGPASSWORDY"
url=“https://hgdata.atlassian.net/rest/api/2/search?jql=project=HG&fields=key,summary,description&maxResults=100” >

the tag use is found here: <cfhttp> :: Lucee Documentation

Thank you for the quick response Terry. I had already tried that and got the following error. “Basic authentication with passwords is deprecated.” Instead, I need to pass the “–user” which is “username:token”. I just don’t know the syntax for that.

Maybe you need to use `

cfhttpparam

`

Andreas, thanks for the response. I have tried using cfhttpparam and have had no luck. “user” is not a valid cfhttpparam type. I have tried “header” and “body” as a type with no success.

I finally got it to work! Yay! Andreas, you got me into digging more into the cfhttpparam option. Here is the solution.

< cfhttp
method=“get”
url=“https://hgdata.atlassian.net/rest/api/2/search?jql=project=HG&fields=key,summary,description&maxResults=100”>
< cfhttpparam type=“header” name=“Accept” value=“application/json”>
< cfhttpparam type=“header” name=“Authorization” value=“Basic TOKEN-GOES-HERE”>

Thank you both @andreas and @Terry_Whitney for your feedback.

2 Likes