Skip Navigation

Loading Webkit View with POST data

Sabre Red 360 Software Development Kit provides capability to open WebKit View programmatically with POST data.

The following code snippet demonstrates how to loads url with post data within view:

public class ExampleWebkitView extends WebkitView
{
    @Override
    public void setUrl(String url, String postData, Map <String, String> extraHeaders)
    {
        url ="http://sabre.com/";
        postData="key1=value1&key2=value2";
        extraHeaders = new HashMap<>();
        extraHeaders.put("Content-Type", "Text/Plain");
        extraHeaders.put("Header1", "test header");
        super.setUrl(url, postData, extraHeaders);
    }
}

Sabre Red 360 Software Development Kit provides setUrl three methods with different parameters.

  • setUrl(String url) - basic method used for loading url in View

  • setUrl(String url, String postData) - method used for loading url with POST data

  • setUrl(String url, String postData, Map<String, String extraHeaders) - method which allows to set headers to request along with post data

The parameters are:

  • url - String value, represents URL of resource that will be loaded.

  • postData - String value, represents POST data in key=value&key=value format.

  • extraHeaders - Map<key, value>, contains headers. If set and if POST data are sent then it must contain Content-Type header.