Link to home
Start Free TrialLog in
Avatar of gdemaria
gdemariaFlag for United States of America

asked on

Try to Receive and API call, but no data?

I am setting up an integration with a third party.   They already have an existing POST to a former affiliate, so I ask them to just put my URL in there and hit our site.  I figured I would just deserialize the JSON and see what comes in, then code to that.  

So I created a   index.cfm file (Coldfusion 11)  on    www.mysite.com/api/order/    

The index.cfm file does nothing but email me a CFDUMP of the URL and FORM variables.
I gave the URL to the company and they hit it.   I receive the email and both CFDUMPs are empty structures.   No URL variables, no FORM variables.

They say they are doing a POST call to the site.   And are using this path:     www.mysite.com/api/order/   

They have hit it multiple times, they get a 200 OK response.   But each time, my mailed dump show empty values even though they are sending JSON over.

What am I missing?    What do I have to do differently to see the data they are sending?

Thanks!
Avatar of Coast Line
Coast Line
Flag of Canada image

Hi,

try wrapping your code in cftry/cfcatch and try the headers call first before the post and see if you get anything, just directly dump the cfhttp response
Avatar of gdemaria

ASKER

Hi Gurpreet,
Thanks for responding.   Please note that I am receiving the API, not making the call.   I don't have a CFHTTP call.
The only thing my code does is cfmail a dump of the URL and FORM scopes.   I am trying to receive an API call to this file.
Even the call to my file has data, I get nothing in these variables.   Not sure what I am doing wrong.
Thanks
ok i get it now, are you using any kind of framework for this or its just raw coldfusion code
No framework, my receiving code is literally a CFMAIL dumping the URL and FORM variables.

It may be the case that the 3rd party is not associating the data to a variable.   Not sure what that even means but in my testing, if I remove the variable name from my post and only send data, CF does not show any variable values in URL or FORM
Maybe the data is there, but CF isn't automatically decoding variables into the URL/FORM scopes?  Try adding a call to GetHTTPREquestData() and dumping the values so you can view what's coming across in the http request (headers and what not). I vaguely recall seeing that happen in a few cases, but am blanking on "why".  Not sure if it was something expected when doing X or Y - or if it was an error in how the data was sent.

https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-e-g/gethttprequestdata.html
ASKER CERTIFIED SOLUTION
Avatar of _agx_
_agx_
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fantastic!   Thanks agx.   I thought exploring just that, but I couldn't find how to retrieve the data, that function did it.

very much appreciated!
You're welcome.  Sounds like we discovered the whole request body thing the same way. Before that I'd always thought FORM was populated whenever you did a POST. I was surprised to find out you could do a POST without any form fields!
Right, exactly.   I discovered PostMan for testing and was able to reproduce the issue to my own api (much better than bothering the 3rd party repeatedly).   It's exactly as you said by just putting the data in the body.  

Thanks again!