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

Request method

New Here ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

I am trying to get the 'request method' (POST, PUT, GET), but somehow it doesn't work.

On localhost I do get the request method used back correctly, only on our server it always returns 'GET'.

When I put the code on the server in a different folder I do get the method back.

What should I be looking for that might overrule or change the 'request method'?

Tested with: GetHttpRequestData().method and cgi.REQUEST_METHOD

Using: Postman

On ColdFusion: 11

Background: working with CF11 but without CF11 devs. trying to maintain code from my PHP experience.

Any help would be greatly appreciated, thanks!

Views

294

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

correct answers 1 Correct answer

Community Expert , Dec 11, 2017 Dec 11, 2017

The HTTP verb you send with your request will control the request method. This is entirely controlled by the browser. Usually, it's going to be "GET", but if you fill out a form with METHOD="POST", it'll be "POST". In Postman, you can control the HTTP verb you use.

If you're already doing that, and are still seeing "GET", there's probably some HTTP redirect happening between the request you send and the response you're looking at.

Dave Watts, CTO, Fig Leaf Software

Votes

Translate

Translate
Community Expert ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

The HTTP verb you send with your request will control the request method. This is entirely controlled by the browser. Usually, it's going to be "GET", but if you fill out a form with METHOD="POST", it'll be "POST". In Postman, you can control the HTTP verb you use.

If you're already doing that, and are still seeing "GET", there's probably some HTTP redirect happening between the request you send and the response you're looking at.

Dave Watts, CTO, Fig Leaf Software

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 ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Yep, since you say it acts differently in a differently folder, I wondered if your application.cfc or cfm of the request in question might have in it some code doing a CFLOCATION or other form of redirect, that was causing the request method to change to a get.

Or you may look to see if your web server (IIS or Apache) has any sort of URL Rewrite processing going on, as that too would lose the original request method.

/charlie


/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
New Here ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

Thank you for your reply.

I am passing along the correct method in Postman. Double checked this by looking at the 'code' http and curl request.

However, we do have some redirects in place.

They appear in the IIS -> URL Rewrite, but originate from a 'web.config', an example:

{code} <rule name="Data API" stopProcessing="true">

                    <match url="^_Api/Data/(\w+)/?$" />

                    <action type="Rewrite" url="_Api/Data/?Scope={R:1}" />

                </rule>

{code}

We also have quite a long application.cfc mostly doing security stuff and setting some environment stuff.

The web.config and application.cfc are the same as on local.

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 ,
Dec 11, 2017 Dec 11, 2017

Copy link to clipboard

Copied

LATEST

Update:

Thanks guys, you were both right, the issue was in the redirect.

I was testing with postman against 'http://' instead of 'https://'.

The application forwarded my calls to 'https://', losing relevant part of the request.

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