HTTP Request - ExecuteAsync Method

Execute the request asynchronously

Member of HTTP Request (PRIM_WEB.HttpRequest)

Details

The ExecuteAsync method is used to execute the HTTPRequest asynchronously.
 
Once the request is submitted, processing will continue, ensuring that user interaction isn't blocked.
 
The use of asynchronous requests is recommended over synchronous requests.

Example

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 := "http://api.openweathermap.org" + #Resource
 
   #Request.ExecuteAsync
 
   Evtroutine Handling(#Request.Completed)
 
      If (#Request.Response *IsNot *null)
 
      Case (#Request.Response.Status)
      When (= 200)
 
         #Com_owner.Update( #Request.Response.JSON.RootItem )
 
      Otherwise
 
         #Com_owner.UpdateForFailure( #Request )
 
      Endcase
 
      Endif
 
   Endroutine
 
Endroutine

See also

All Component Classes

Technical Reference

Febuary 18 V14SP2