HTTP Request (PRIM_WEB.HttpRequest)

HTTP request to an external web resource

Ancestors - Object (PRIM_OBJT)


An HTTPRequest allows access to 3rd party HTTP services, allowing LANSA to integrate with other web services.
An HTTPRequest is effectively a standard XMLHttpRequest in JavaScript.
HTTPRequests should be defined within the routine in which they are going to execute. This will create a new instance every time one is executed. The corresponding event routines for the Completed and Failed events are coded in the same routine.
The LANSA runtime maintains the instances until they have finished. This allows the same routine to be execute many times and many requests to execute, each one independently producing results.
If the HTTPRequest exists as a global scope, there will only ever be one instance.
HTTPRequest instances can't be defined with an EVTROUTINE as events cannot have other child events routines.


In this example, a weather API is executed asynchronously, returning the data as a JSON object.
When the completed event fires, the result is processed.
Mthroutine Name(GetWeather) Access(*Private)
   Define_Map For(*Input) Class(#prim_alph) Name(#Resource)
   Define_Com Class(#PRIM_WEB.HttpRequest) Name(#Request)
   #Request.URL := "" + #Resource
   Evtroutine Handling(#Request.Completed)
      If (#Request.Response *IsNot *null)
      Case (#Request.Response.Status)
      When (= 200)
         #Com_owner.Update( #Request.Response.JSON.RootItem )
         #Com_owner.UpdateForFailure( #Request )


ComponentClassNameComponentClassName is the name of the component's class. Inherited from Object (PRIM_OBJT)
ComponentMembersComponentMembers provides access to all the member components of this component Inherited from Object (PRIM_OBJT)
ComponentPatternNameComponentPatternName is used to qualify the class of the component. Inherited from Object (PRIM_OBJT)
ComponentTagGeneric space allowing a value to be stored for the instance Inherited from Object (PRIM_OBJT)
ComponentTypeComponentType gives you access to the type information about the component Inherited from Object (PRIM_OBJT)
ComponentTypeNameComponentTypeName is the fully qualified name of the component's class. Inherited from Object (PRIM_OBJT)
ContentThe content of an HTTP request
HeadersHTTP Headers
MethodStandard HTTP request methods such as GET, POST etc.
NameName identifies the component Inherited from Object (PRIM_OBJT)
OwnerOwner owns this component Inherited from Object (PRIM_OBJT)
ParentThe component instance to which this instance is attached. The visual container for a control or the collector of a set of child instances Inherited from Object (PRIM_OBJT)
ResponseReference to an HTTP Response object returned by the request
StatusStandard HTTP request status code
TimeoutStandard HTTP request timeout
UrlURL of the request


CompletedFired when the HTTP request returns after processing successfully
CreateInstanceCreateInstance is signalled when an instance of a component is created Inherited from HTTP Request (PRIM_WEB.HttpRequest)
DestroyInstanceDestroyInstance is signalled when an instance of a component is about to be destroyed Inherited from HTTP Request (PRIM_WEB.HttpRequest)
FailedFired when the HTTP request returns after processing unsuccessfully


CancelCancel the HTTP request
ExecuteExecute the Request synchronously
ExecuteAsyncExecute the request asynchronously

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2