Удалить шаблон с помощью Java
Удалить шаблон с помощью Java
Java : ДОКУМЕНТАЦИЯ API
- Создать группу с Java
- Получить список полей группы с помощью Java
- Добавить поле в группу с Java
- Удалить поле из группы с Java
- Удалить контакт из группы
- Предоставление страны электронной группе с Java
- Получить список контактов группы с помощью Java
- Добавить контакт в группу с Java
- Изменить контакт группы с помощью Java
- Удалить контакт группы с Java
Удалить шаблон с помощью Java
String afilnet_class="template";
String afilnet_method="deletetemplate";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_idtemplate="1000";
// Create an URL request
String sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&idtemplate="+afilnet_idtemplate;
URL url = new URL(sUrl);
StringBuilder builder = new StringBuilder();
BufferedReader theJSONline = new BufferedReader(new InputStreamReader(url.openStream()));
builder.append(theJSONline.readLine());
String content = builder.toString();
String afilnet_class="template";
String afilnet_method="deletetemplate";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_idtemplate="1000";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&idtemplate="+afilnet_idtemplate;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/http/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
String afilnet_class="template";
String afilnet_method="deletetemplate";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_idtemplate="1000";
// Create the POST request
String post = "class="+afilnet_class+"&method="+afilnet_method+"&idtemplate="+afilnet_idtemplate;
// We generate the URL
URL myurl = new URL("https://www.afilnet.com/api/basic/");
// We create the connection
HttpURLConnection con = (HttpURLConnection) myurl.openConnection();
String encoded = Base64.getEncoder().encodeToString((afilnet_user+":"+afilnet_password).getBytes(StandardCharsets.UTF_8));
con.setRequestProperty("Authorization", "Basic "+encoded);
con.setDoOutput(true);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length", String.valueOf(post.length()));
con.setRequestMethod("POST");
// We build the
OutputStream os = con.getOutputStream();
os.write(post.getBytes());
os.close();
StringBuilder sb = new StringBuilder();
int HttpResult = con.getResponseCode();
if(HttpResult == HttpURLConnection.HTTP_OK)
{
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
String line = null;
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
br.close();
System.out.println(""+sb.toString());
} else {
System.out.println(con.getResponseCode());
System.out.println(con.getResponseMessage());
}
параметр | Описание | Обязательный / Необязательный |
---|---|---|
class=template | Запрошенный класс: класс, к которому сделан запрос | обязательное |
method=deletetemplate | Запрошенный метод класса: метод класса, к которому сделан запрос | обязательное |
user | Пользователь и адрес электронной почты вашей учетной записи Afilnet | обязательное |
password | Пароль вашей учетной записи Afilnet | обязательное |
idtemplate | Идентификатор шаблона | обязательное |
При отправке запросов вы получите следующие поля:
- status
-
результат (если статус = успех), здесь вы получите следующие значения:
- Никакие дополнительные значения не будут отправлены вам
- ошибка (если статус = ошибка), здесь вы получите код ошибки
Возможные коды ошибок перечислены ниже
Код | Описание |
---|---|
MISSING_USER | Пользователь или адрес электронной почты не включены |
MISSING_PASSWORD | Пароль не включен |
MISSING_CLASS | Класс не включен |
MISSING_METHOD | Метод не включен |
MISSING_COMPULSORY_PARAM | Обязательный параметр не включен |
INCORRECT_USER_PASSWORD | Неверный пользователь или пароль |
INCORRECT_CLASS | Неправильный класс |
INCORRECT_METHOD | Неправильный метод |
NOT_ACCESS_TO_TEMPLATE | У вас нет доступа к выбранному шаблону |
ERROR_ASSIGNED_EVENT | Вы не можете удалить группу, потому что существуют события, связанные с этой группой |
Параметры:
- class : template
- method : deletetemplate
- user : user
- password : password
- idtemplate : 1000
Запрос:
https://www.afilnet.com/api/http/?class=template&method=deletetemplate&user=user&password=password&idtemplate=1000