Exemple #1
0
 public ResourceRequestXamarinFormsPage()
 {
     Debug.WriteLine("Before initialize");
     InitializeComponent();
     _this          = this;
     BindingContext = new ViewModel();
 }
        private async void SubmitValues()
        {
            User _UserFromPage = ResourceRequestXamarinFormsPage.GetTextValues();

            IWorklightClient _newClient = App.GetWorklightClient;

            StringBuilder uriBuilder = new StringBuilder().Append("/adapters/JavaAdapter/users")
                                       .Append("/").Append(_UserFromPage.FirstName)
                                       .Append("/").Append(_UserFromPage.MiddleName)
                                       .Append("/").Append(_UserFromPage.LastName);

            WorklightResourceRequest rr = _newClient.ResourceRequest(new Uri(uriBuilder.ToString(), UriKind.Relative), "POST", "");

            rr.SetQueryParameter("age", _UserFromPage.Age);

            System.Net.WebHeaderCollection headerCollection = new WebHeaderCollection();

            headerCollection["birthdate"] = _UserFromPage.BirthDate;

            rr.AddHeader(headerCollection);

            Dictionary <string, string> formParams = new Dictionary <string, string>();

            formParams.Add("height", _UserFromPage.Height);

            WorklightResponse resp = await rr.Send(formParams);

            Debug.WriteLine(resp.ResponseJSON);

            ResourceRequestXamarinFormsPage.DisplayOutput(resp.ResponseText);
        }