0

I have looked at the other posts on this subject but nothing seemed to address this issue.

The following curl request works against our test database:

curl -XGET 'http://larry:larson@collection.aboutdrawing.org/service.php/find/ca_objects?q=*' -d '{"bundles" : { "ca_objects.access" : { "convertCodesToDisplayText" : true }, "ca_objects.status" : { "convertCodesToDisplayText" : true }, "ca_entities.entity_id" : {"returnAsArray" : true }}}'

However, my attempt to make this work in CF does not return the fields specified in the -d part of the curl request.

<cfoutput>
<cfset strFields = {"bundles" : { "ca_objects.access" : { "convertCodesToDisplayText" : true }, "ca_objects.status" : { "convertCodesToDisplayText" : true }, "ca_entities.entity_id" : {"returnAsArray" : true }}}>
    <cfhttp url="http://larry:larson@collection.aboutdrawing.org/service.php/find/ca_objects?q=*" 
    method="get" 
    result="httpResp" 
    timeout="60"
    useragent="#cgi.http_user_agent#">
    <cfhttpparam type="body" value="#serializeJSON(strFields)#"  >
    </cfhttp>
   <cfdump var="#httpResp#" > 
</cfoutput> 

Can anyone offer any insight?

Thank you

1 Answers1

0

I would highly recommend using a proxy tool like fiddler. Install it and run it and it'll be acting as a proxy on localhost port 8888.

re-run your curl command proxying it through fiddler:

curl -x localhost:8888 -XGET 'http://larry:larson@collection.aboutdrawing.org/service.php/find/ca_objects?q=*' -d '{"bundles" : { "ca_objects.access" : { "convertCodesToDisplayText" : true }, "ca_objects.status" : { "convertCodesToDisplayText" : true }, "ca_entities.entity_id" : {"returnAsArray" : true }}}'

Now modify your cfhttp call:

 <cfhttp url="http://larry:larson@collection.aboutdrawing.org/service.php/find/ca_objects?q=*" 
    method="get" 
    result="httpResp" 
    timeout="60"
    proxyServer="localhost"
    proxyPort:"8888"
    useragent="#cgi.http_user_agent#">

You can now see the requests/responses of both CFHTTP and cURL in one place. Use the inspectors tab to look at the differences and I suspect that'll tell you where the problem is. If you use a diffing tool, Fiddler can be set up to use that to compare two sessions, which makes the process even more straightforward.

Also, I'm not sure if you're building the API that you're talking to, but it appears to require a request body in a GET, which isn't normally used

Community
  • 1
  • 1
barnyr
  • 5,603
  • 17
  • 28