IS.HTTPCLIENT - Using Universe and UniData HttpCall Extensions

Universe and Unidata have built in UniBASIC extensions that make the job of calling to a HTTP web server relatively easy. If you look into the UniVerse and/or UniData BASIC extension manual, you will see references to the CallHTTP functions that were added.

These functions isolate a lot of the complexity of writing the HTTP protocols by hand, but they still require you to do some work. The subroutine included with this article removes that set of complexity by creating a single subroutine that you can call.

    This is the HTTP Method you are asking the web server to process. Normally, this is either 'GET' or 'POST'
  • URL
    This is the "Http://" or "Https://" want to request data from or send data to.
  • HEADER.DATA<1,n>
    Http Request Header Name - This is the header name that the developer wants to included with the request to the server.
  • HEADER.DATA<2,n>
    Http request Header data - This is the data you want to include with this header name
  • POST.DATA<-1>
    This is the data you want to send to the web server. Each AM (Char(254)) will be converted to a CRLF.
    Http response returned by the web server. That values are between 100-500. Most successful request will return with a value of 200 or 201 as per the HTTP protocol.
    Header Names returned with the response data. This is provided by the web server, and may include important information.
    Value for the header data
  • RESP.DATA<n>
    This is the data returned by the web server based on the URL, HTTP.METHOD, and POST.DATA. Each CRLF will be converted into an AM mark (char(254))
    All other communication errors, parsing error, or anything not related to the HTTP protocol will be returned here. If there is no error, then this will return '' or '0'


CRT "Error ": ERROR

CallHTTP Extension Gotchas

Depending on the version of UniVerse or UniData there are a few gotcha. If you are running a UniVerse or UniData on a 64bit operation systems, then the access to Https may be be available. This is a common problem on some version of AIX.

Another issue you may into is trying to send anything other than a Username:password value in 'Authorization' Request header. If you add it using setRequestHeader, you will receive an error message. If you try to set the value using setHTTPDefault, you will also receive an error message.

In most causes this is not a problem, unless you are looking to use OAUTH with your web service/RESTful service call.


If you are looking for alternatives to address these short comings, then look at the HttpClient - CURL version or the HTTP client using sockets.

License Notes:

This program is free software in the public domain; you can redistribute it and/or modify it in any way you wish. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Commercial support and warranties of this software and code can be purchased through International Spectrum.

This program is not the only means to do this, but is a starting point or working sample that can be extended.


International Spectrum

Located in Thorton CO.

View more articles