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!
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
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
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
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.
Copy link to clipboard
Copied