Web Connection
How to with loHTTP.HTTPGetEx
Gravatar is a globally recognized avatar based on your email address. How to with loHTTP.HTTPGetEx
  Joy Tan
  All
  Dec 21, 2021 @ 06:17pm

HI Rick,

I got this working with your latest version. But I need to get it working for a legacy application (version 2013)

Latest version code:

local lohttp as wwhttp
loHttp = CREATEOBJECT("wwHttp")
loHttp.AddHeader("Authorization",lcAuthToken2)
loHttp.cContentType = "application/json"
lcResult = loHttp.Post(lcUrl, lcJson)

Trying to get the equivalent

*** Connect to the server
loHTTP.HTTPConnect(lcserver)
loHTTP.AddPostKey("",lcJson)
lcHTML=""
lnText=0
lnResult=loHTTP.HTTPGetEx('lcurl',@lcHTML,@lnText)

Using the above is not working (HTTPGetEx) Any ideas?

Thanks Joy Tan

Gravatar is a globally recognized avatar based on your email address. re: How to with loHTTP.HTTPGetEx
  Joy Tan
  Joy Tan
  Dec 22, 2021 @ 12:31pm

HI Rick,

Disregard this post, I found the answer.

Thank you so much. Joy

Gravatar is a globally recognized avatar based on your email address. re: How to with loHTTP.HTTPGetEx
  Rick Strahl
  Joy Tan
  Dec 22, 2021 @ 03:52pm

You should never be using HttpGetEx() any longer even with the old version you've been using. The method to use is HttpGet(). HttpGetEx() requires a lot of extra code and potential for errors, when HttpGet() does all the same work with a single command that cleans up after itself. It's more reliable and behind the scenes it calls HttpGetEx() to do the real work but fixes up results and cleans up the connection.

For even that version you should be using HttpGet() which is the Master Function through which all requests flow regardless of HTTP verb (even now - methods like .Post() just call through to HttpGet()).

local lohttp as wwhttp
loHttp = CREATEOBJECT("wwHttp")
loHttp.AddHeader("Authorization",lcAuthToken2)

*** This shouldn't be necessary except in a really old version
* loHttp.nHttpPostMode = 4  && raw/xml

loHttp.cContentType = "application/json"  
loHttp.AddPostKey(lcJson)     && raw data buffer
lcResult = loHttp.HttpGet(lcUrl)

This code works in the current version and should also work in old versions.

If the version is really old you may have to set nHttpPostMode to 4 and then set the cContentType afterwards.

+++ Rick ---

© 1996-2022