Show TOC

Making HTTP Get Requests from Whitelisted ConnectionsLocate this document in the navigation structure

Make HTTP Get requests from either whitelisted OData or JSON service connections.


Define a whitelisted back-end connection used by the application in SAP Mobile Platform Server using Management Cockpit.


  1. If the whitelisted connection is an OData service:
    1. Create a new instance of ODataStore: var store = new ODataStore(“Uri");
    2. Follow the steps Making HTTP Get Requests.
  2. If the whitelisted connection is a JSON service:
    1. Create a new instance of SAP.Net.Http.HttpClient that is initialized with credentials from the DataVault, add the application connection ID as a header, and submit the request asynchronously.
    2. Use native JSON libraries to parse response:
      //Add a new System.Net.Http.HttpClientHandler in the constructor for SAP.Net.Http.HttpClient() 
      //to pass in the credentials
      var client = new SAP.Net.Http.HttpClient(
          new System.Net.Http.HttpClientHandler()
             Credentials =
                new System.Net.NetworkCredential(
          true); // will be disposed by the store!
      client.DefaultRequestHeaders.TryAddWithoutValidation("X-SMP-APPCID", connectionId);
      // Send a request asynchronously continue when complete
       HttpResponseMessage response = await client.GetAsync(url);
      // Check that response was successful or throw exception
      // Read response asynchronously as JsonValue and write out top facts for each country
      var content = await response.Content.ReadAsStringAsync();
      // Parse it into an JsonObject
      var jsonContent = JsonObject.Parse(content);
      var airport = jsonContent.GetNamedValue("name").GetString();