Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public PrintResponse Send(Request data, Konfiguration config)
- {
- Uri uri = new Uri($"{BaseAddress}/Api/Send");
- var content = new FormUrlEncodedContent(new[]
- {
- new KeyValuePair<string, string>("data", JsonConvert.SerializeObject(data)),
- new KeyValuePair<string, string>("config", JsonConvert.SerializeObject(config))
- });
- return CallApiMethod<PrintResponse>(uri, encodedContent);
- }
- public T CallApiMethod<T>(Uri uri, StringContent content)
- {
- var response = client.PostAsync(uri, content).GetAwaiter().GetResult();
- var responseContent = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception(responseContent);
- }
- }
- [HttpPost]
- public Response Send([FromBody] JObject data)
- {
- Request Request = null;
- if (data["data"] != null)
- {
- Request = JsonConvert.DeserializeObject<Request>(data["data"].ToString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement