FoxPro Programming
Using West Wind Client Tools for HTTP post
Gravatar is a globally recognized avatar based on your email address. Using West Wind Client Tools for HTTP post
  Bob
  All
  May 20, 2024 @ 02:55am

I am trying to replace an ActiveX control with procedures from “West Wind Client Tools”. The procedure sends a URL string as an HTTP post and returns a response which can be either xml, csv or text. This is done in one command in the ActiveX control. I have been trying to replicate this using function: post in wwhttp but so far have not been successful. Is there a function available in Client Tools that would send a single URL string like the one shown and return a single result string? Thanks for any help you can provide.

https://vault.trustcommerce.com/trans/?device_name=A920PRO_1850408938&custid=*******&password=varPassword&aggregators=1&aggregator1=******&action=sale
Gravatar is a globally recognized avatar based on your email address. re: Using West Wind Client Tools for HTTP post
  Rick Strahl
  Bob
  May 20, 2024 @ 08:44am

I'm not sure your request is a POST operation if you're passing all those parameters on the query string. That would be a GET request:

DO wwHttp && load libraries

loHttp = CREATEOBJECT("wwHttp")
lcResult = loHttp.Get("https://vault.trustcommerce.com/trans/?device_name=A920PRO_1850408938&custid=*******&password=varPassword&aggregators=1&aggregator1=******&action=sale")

? lcResult

If you do need to use a post:

DO wwHttp && load libraries

loHttp = CREATEOBJECT("wwHttp")
loHttp.AddPostKey("device_name","A9....")
loHttp.AddPostKey("custid","123123")
loHttp.AddPostKey("password", "supperseekrit")
...
lcResult = loHttp.Post("https://vault.trustcommerce.com/trans/")

? lcResult

If you have raw post data you can set the loHttp.cContentType and use loHttp.Post(lcUrl, lcRawData).

Most of the different ways you can use wwHttp are shown here:

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using West Wind Client Tools for HTTP post
  Bob
  Rick Strahl
  May 20, 2024 @ 09:31am

Obviously you are so right. I don't know a post from a get. Once I changed the call, it worked like a champ. After you call wwhttp and get the result is there anything that needs to be released before calling it again.

if you are going to be calling multiple functions in wwhttp or any other wwprogram is it more efficient to put the initial do wwhttp command in a higher program and just do the createobject commands as needed? Does the object need to be released at any point?

Just curious.

Gravatar is a globally recognized avatar based on your email address. re: Using West Wind Client Tools for HTTP post
  Rick Strahl
  Bob
  May 20, 2024 @ 10:45am

I prefer to create a new instance - HTTP calls are transactional and self-contained so there's no benefit to hang on to that instance. And the object has almost no state so there's no overhead.

But you can reuse if you choose to.

+++ Rick ---

© 1996-2024