PUT /api/wip
API 令牌
应通过“生成令牌 API”命令生成令牌Generate API Key
PUT body
要列入白名单的 IP。例如,
ip="1.2.1.2"curl -X PUT "http://127.0.0.1:22999/api/wip" -H "Authorization: API key" -H "Content-Type: application/json" -d '{"ip":"1.2.1.2"}'
#!/usr/bin/env node
require('request-promise')({
method: 'PUT',
url: 'http://127.0.0.1:22999/api/wip',
json: {'ip':'1.2.1.2'},
headers: {'Authorization': 'API key'},
}).then(function(data){ console.log(data);},
function(err){ console.error(err); });
package example;
import org.apache.http.HttpHost;
import org.apache.http.client.fluent.\*;
public class Example {
public static void main(String[] args) throws Exception {
String body = "{\"ip\":\"1.2.1.2\"}";
String res =Executor.newInstance()
.addHeader("Authorization", "API key")
.execute(Request.Put("http://127.0.0.1:22999/api/wip")
.bodyString(body, ContentType.APPLICATION_JSON))
.returnContent()
.asString();
System.out.println(res)
}
}
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
public class Program {
public static async Task Main() {
var client = new HttpClient();
var requestMessage = new HttpRequestMessage {
Method = HttpMethod.Put,
RequestUri = new Uri("http://127.0.0.1:22999/api/wip"),
Headers = {{"Authorization", "API key"}},
Content = new StringContent(JsonConvert.SerializeObject(new {
ip = "1.2.1.2"
}), Encoding.UTF8, "application/json")
};
var response = await client.SendAsync(requestMessage);
var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
#!/usr/bin/env python
import json
import requests
data = {'ip':'1.2.1.2'}
headers = {'Authorization': 'API key'}
r = requests.put(
'http://127.0.0.1:22999/api/wip',
data=json.dumps(data),
headers=headers
)
print(r.content)
Successful response
Bad request. No IP was passed
Forbidden. No authentication provided
Unprocessable entity. Invalid IP was passed