-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRelinkProcessor.cs
42 lines (35 loc) · 1.13 KB
/
RelinkProcessor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using Newtonsoft.Json;
namespace WitProjekt
{
class RelinkProcessor
{
public static async Task<RelinkModel> PostLink(string link = "")
{
string baseUrl = "https://rel.ink/api/links/";
var inputObject = new Dictionary<string, string>
{
{ "url", link}
};
var inputBody = JsonConvert.SerializeObject(inputObject);
StringContent queryString = new StringContent(inputBody, Encoding.UTF8, "application/json");
using (HttpResponseMessage response = await Api.ApiClient.PostAsync(baseUrl, queryString))
{
if (response.IsSuccessStatusCode)
{
RelinkModel relink = await response.Content.ReadAsAsync<RelinkModel>();
return relink;
}
else
{
throw new Exception(response.ReasonPhrase);
}
}
}
}
}