Hi i am trying replicate this call by PHP to Coldfusion:
The call must be by method GET but passing data json in body {“parameter”: “2222222”}
In PHP works fine but in coldfsuion no.
Also, what is it that doesn’t work? Can you share any error message if not also the dump of your res variable?
Also, have you tried outputting your SerializeJSON({“param”:”22222222″}), to make sure that really looks like what you show sending in the php code?
Note also that your php code sets curl_setopt($ch, CURLOPT_POSTFIELDS, which according to the php docs is for sending a form POST, though I see also the use of CURLOPT_CUSTOMREQUEST, ‘GET’);.
Have you at least TRIED doing a method=”post” instead of get?
Finally, here’s something else to consider: is the php running from the same machine as cf? If not, try making the call using the free postman tool, first from your machine with php, then from the machine with CF. Your issue may not be with CF itself.
Or maybe someone else may have more on your specific goal.
I seem to remember running into this issue years ago. Ah yes. This StackOverflow answer gives the gist of it:
https://stackoverflow.com/questions/978061/http-get-with-request-body#983458
Long story short:
“A payload within a GET request message has no defined semantics; sending a payload body on a GET request might cause some existing implementations to reject the request.”
Basically, a GET request is not expected to have a BODY, and the server doesn’t know how to handle it when it gets it.
If you can, check the target server and see what it’s receiving in the body. You may need to convert the body into URL parameters instead.
You must be logged in to post a comment.