c가이드

30.Jun.2021

curl

 

curl --location --request POST 'https://yourwebsite.com/api/url/add' \
  --header 'Authorization: Token YOURAPIKEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "url": "https://google.com",
      "custom": "google",
      "password": "mypass",
      "domain": "http://goo.gl",
      "expiry": "2020-11-11 12:00:00",
      "type": "splash",
      "geotarget": [{
          "location": "Canada",
          "link": "https://google.ca"
        },
        {
          "location": "United States",
          "link": "https://google.us"
        }
      ],
      "devicetarget": [{
          "device": "iPhone",
          "link": "https://google.com"
        },
        {
          "device": "Android",
          "link": "https://google.com"
        }
      ]
    }'

 

 

 

 

c#/.NET

 

var url = "https://yourwebsite.com/api/url/add";

var httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.Method = "POST";

httpRequest.Headers["Authorization"] = "Token YOURAPIKEY";
httpRequest.ContentType = "application/json";

var data = @"{
      ""url"": ""https://google.com"",
      ""custom"": ""google"",
      ""password"": ""mypass"",
      ""domain"": ""http://goo.gl"",
      ""expiry"": ""2020-11-11 12:00:00"",
      ""type"": ""splash"",
      ""geotarget"": [{
          ""location"": ""Canada"",
          ""link"": ""https://google.ca""
        },
        {
          ""location"": ""United States"",
          ""link"": ""https://google.us""
        }
      ],
      ""devicetarget"": [{
          ""device"": ""iPhone"",
          ""link"": ""https://google.com""
        },
        {
          ""device"": ""Android"",
          ""link"": ""https://google.com""
        }
      ]
    }";

using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
{
   streamWriter.Write(data);
}

var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
   var result = streamReader.ReadToEnd();
}

Console.WriteLine(httpResponse.StatusCode);

소셜링크