• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

ColdFusion 2016 Rest API to SCOUT - Content-Type: application/vnd.api+json

New Here ,
Jan 22, 2020 Jan 22, 2020

Copy link to clipboard

Copied

I am attempting to run a simple REST api with ColdFusion and receiving same error regardless of attempt. The call works fine in Postman with the 4 params. But cant recreate in ColdFusion 2016 CFHTTP.

<cfhttp url="https://api.sandbox.scoutrfp.com/v3/contracts" method="GET" result="ITEM_INFO">

        <cfhttpparam type="header" name="X-Api-Key" value="#variables.API_KEY#">

        <cfhttpparam type="header" name="X-User-Token" value="#variables.USER_TOKEN#">

        <cfhttpparam type="header" name="Content-Type" value="application/vnd.api+json">

        <cfhttpparam type="header" name="X-User-Email" value="#variables.USER_EMAIL#">

</cfhttp>

I have replaced the header with type cgi as

<cfhttpparam type="CGI" encoded="false" name="Content_Type" value="application/vnd.api+json">

I have added all temp headers that postman sends.

Always same error: Missing or incorrect Content-Type header for JSON:API: Expected request to include 'Content-Type: application/vnd.api+json

Seems CFHTTP tag not properly sending value "application/vnd.api+json" - perhaps encoding it incorrectly in some fashion? Is there another means to send this Content-Type via CFHTTP to get a response?

TOPICS
Advanced techniques

Views

879

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

Two tips:

 

1) method="POST"

 

2) Any luck with this?

<cfhttpparam type="header" name="Content-Type" value="application/vnd#chr(46)#api#chr(43)#json">

 

Or this?

<cfhttpparam type="header" name="Content-Type" value="application/vnd#chr(46)#api#chr(43)#json;charset=UTF-8">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

appreciate the reply...but neither of those worked.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

Our posts crossed. I was still editing mine.

What happens when you switch to "POST" method?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

I will try any and all 😉

attempted as POST also with both headers also...same errors.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2020 Jan 27, 2020

Copy link to clipboard

Copied

LATEST

Sorry to hear that.

Perhaps the content-type application/vnd.api+json is too new for ColdFusion.

 

You could, as an alternative, install CURL, then do something like:

(The intention is to save the result in the current directory. That is, the directory containing this CFM file)

 

<!--- Use your own path to the Curl executable --->

<cfexecute name = "C:\bin\curl-7.35.0-win64\bin\curl.exe" 
     arguments = ' -H "X-Api-Key:#variables.API_KEY#" -H "X-User-Token:#variables.USER_TOKEN#" -H "Content-Type:application/vnd.api+json" -H  "X-User-Email:#variables.USER_EMAIL#" https://api.sandbox.scoutrfp.com/v3/contracts ' 
outputfile="#expandPath('.')#\ITEM_INFO.html" />

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation