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

CF18 - The @FormParam is utilized when the content type of the request entity is not

Explorer ,
Oct 10, 2019 Oct 10, 2019

Copy link to clipboard

Copied

Started seeing some weird message today in my CF18 environment. The message is "The @FormParam is utilized when the content type of the request entity is not application/x-www-form-urlencoded" when calling a CF REST service in a cfc file. This has worked as recent as a week ago so not sure why it would be an issue now. Has anyone expereicned this before? The call we make to the REST service is shown below. I am thinking it is related to tthe headers but not sure if that value should be something different.

 

$http({

method: 'POST',

url: strServiceUrl + 'admin/create/' + $scope.selectedRecall.id + '/retailblock/remove',

headers: {'Content-Type': 'application/x-www-form-urlencoded'}

 

Thanks.

Views

2.8K

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 Beginner ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

I'm having this issue too. Did you ever figure out the solution?

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
Explorer ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Hi Phil5C93. I honestly don't remember what was done to fix this. I am looking at that block of code now and it is working and is the same as I show above. The CFC that it references has this for the cfconponent "<cfcomponent output="false" rest="true" restPath="admin/create">". I know on some of my CFC's I have to actually put rest="true" but not sure if that is what we did to fix this issue. You can try it to see if it works, just change the rest path to whatever your path is.  I'll check a few other things to see if it jogs my memory. Also, I am running CF2018 Enterprise update 9 on the server this is running on.

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 ,
Apr 22, 2021 Apr 22, 2021

Copy link to clipboard

Copied

Phil, what cf version are you on? 2018 as well? and what update?

 

And jd, are you still having the issue? If so, what update of cf2018? 


/Charlie (troubleshooter, carehart.org)

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 ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

@Jdsplicer , I have posted a response in Phil5C93's @FormParam thread. I shall repeat it here for your convenience:

 

@FormParam is shorthand for the annotation @javax.ws.rs.FormParam in Java's standard REST API, JAX-RS. ColdFusion 2018's REST API ia an implementation of JAX-RS.

 

@FormParam requires that the request body of the input be of type application/x-www-form-urlencoded. That is, it requires that your service receive input from an HTML form. This in turn implies that the value of the request's Content-Type header must be application/x-www-form-urlencoded.

 

The 2 most likely causes of the error are therefore:

  1. when the REST service expects input from a form (@FormParam), but the request-body/Content-Type is of a type different from application/x-www-form-urlencoded, often application/json;
  2. when the request-body/Content-Type is of type application/x-www-form-urlencoded, but the REST service expects input other than from a form.

 

The likeliest scenario, to cut a long story short:

  • ensure that the form structure isn't first serialized to JSON before it reaches the REST service;
  • where necessary, deserialize the JSON input to a (form) structure and use this in the request to the REST service.

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 ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

LATEST

There is a break in backward compatibility. So, all said and done, what you have observed might be a bug.

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