Highlighted

Request method

New Here ,
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!

Adobe Community Professional
Correct answer by Dave_Watts | Adobe Community Professional

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

Views

200

Likes

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

Request method

New Here ,
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!

Adobe Community Professional
Correct answer by Dave_Watts | Adobe Community Professional

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

Views

201

Likes

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
Dec 11, 2017 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Dec 11, 2017 0
Adobe Community Professional ,
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 (server troubleshooter, carehart.org)

Likes

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
Reply
Loading...
Dec 11, 2017 0
New Here ,
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.

Likes

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
Reply
Loading...
Dec 11, 2017 0
New Here ,
Dec 11, 2017

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...
Dec 11, 2017 0