2

I am trying to repeat the following cURL Example using CFHTTP/CFHTTPPARAM but no luck

    curl https://your-space.signalwire.com/api/relay/rest/jwt \
  -X POST \
  -u 'YourProjectID:YourProjectToken' \
  -H 'Content-Type: application/json'

I've tried appending the #YourProjectID#:#YourProjectToken# directly to the URL, that didnt work..

Here is my CFHTTP code;

<cfhttp method="post" url="#u#" >
    <cfhttpparam  type="url" name="#projectID#" value="#APItoken#"> 
    <cfhttpparam  type="header" name="Content-Type" value="application/json">
</cfhttp>

ANy suggestions on how to structure this?

Ken Mais
  • 31
  • 2
  • 1
    Have you looked at this? https://stackoverflow.com/questions/24933746/getting-basic-authentication-to-work-with-coldfusion – user12031119 Jul 08 '20 at 03:24

1 Answers1

2

If you currently have:

<cfset u = "https://your-space.signalwire.com/api/relay/rest/jwt" />

try to prepend the authentication credentials to the url, like:

<cfset u = "https://" & #projectID# & ":" & #APItoken# & "@your-space.signalwire.com/api/relay/rest/jwt" />
<cfhttp method="post" url="#u#" >
    <cfhttpparam  type="header" name="Content-Type" value="application/json">
</cfhttp>

Another thing you could try would be:

<cfset u = "https://your-space.signalwire.com/api/relay/rest/jwt" />
<cfhttp 
    method="post" 
    url="#u#" 
    username="#projectID#"
    password="#APItoken#" >

    <cfhttpparam type="header" name="Content-Type" value="application/json">
    
</cfhttp>
Alex Baban
  • 11,312
  • 4
  • 30
  • 44