/// <summary> /// Executes a FileMaker Request to a JSON string. /// </summary> /// <param name="method">The http method to use for the request.</param> /// <param name="requestUri"></param> /// <param name="req">The request to execute.</param> /// <returns>The JSON string returned from FMS.</returns> public async Task <HttpResponseMessage> ExecuteRequestAsync( HttpMethod method, string requestUri, IFileMakerRequest req) { var str = req.SerializeRequest(); var httpContent = new StringContent(str, Encoding.UTF8, "application/json"); // do not pass character set. // this is due to fms 18 returning Bad Request when specified // this hack is backward compatible for FMS17 httpContent.Headers.ContentType.CharSet = null; var httpRequest = new HttpRequestMessage(method, requestUri) { Content = httpContent }; // we're about to use the token so update date used, and refresh if needed. await UpdateTokenDateAsync(); // run and return the action var response = await _client.SendAsync(httpRequest); return(response); }
/// <summary> /// Execute the POST request to FMS XML /// </summary> /// <param name="req">The Request To Execute.</param> /// <returns>The HttpResponseMessage From The Request.</returns> private async Task <HttpResponseMessage> ExecuteRequestAsync(IFileMakerRequest req) { var url = _fmsUri + "/fmi/xml/fmresultset.xml"; var requestContent = req.SerializeRequest(); var globals = string.Join("", _globalsToAdd); _globalsToAdd.Clear(); // append fileName to request since thats not represented in the request itself // append globals var sContent = requestContent + globals + $"&-db={_fileName}"; var httpRequestContent = new StringContent(sContent); var response = await _client.PostAsync(url, httpRequestContent); return(response); }
/// <summary> /// Executes a FileMaker Request to a JSON string. /// </summary> /// <param name="method">The http method to use for the request.</param> /// <param name="requestUri"></param> /// <param name="req">The request to execute.</param> /// <returns>The JSON string returned from FMS.</returns> public async Task <HttpResponseMessage> ExecuteRequestAsync( HttpMethod method, string requestUri, IFileMakerRequest req) { var str = req.SerializeRequest(); var httpContent = new StringContent(str, Encoding.UTF8, "application/json"); var httpRequest = new HttpRequestMessage(method, requestUri) { Content = httpContent }; // we're about to use the token so update date used, and refresh if needed. await UpdateTokenDateAsync(); // run and return the action var response = await _client.SendAsync(httpRequest); return(response); }