{
"header": "sample string 1",
"message": "sample string 2",
"sms": true,
"express": true,
"recipients": [
"sample string 1",
"sample string 2"
]
}
Dokumentation för API-funktioner
POST User/Notify/{customerId}
Notifierar användare
Request Information
URI Parameters
Body Parameters
Notification
Response Information
Resource Description
Notifierar användare
boolean
Kodexempel
Testformulär
Text input
Response Formats
| Namn | Beskrivning | Typ | Information |
| customerId | string |
Krävs |
| Namn | Beskrivning | Typ | Information |
| Header | Rubrik | string | |
| Message | Meddelande | string | |
| SMS | SMS notifiering | boolean | |
| Express | Express notifiering | boolean | |
| Recipients | Notifierings mottagare(userId) | Collection of string |
Request Formats
<Notification xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Vitec.Housing.Connect.Api.Models.User">
<Express>true</Express>
<Header>sample string 1</Header>
<Message>sample string 2</Message>
<Recipients xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:string>sample string 1</d2p1:string>
<d2p1:string>sample string 2</d2p1:string>
</Recipients>
<SMS>true</SMS>
</Notification>
curl "https://connect.maklare.vitec.net/User/Notify/StringValue" -X POST -H "Content-Type: application/json" -H "Authorization: basic {Base64 kodad användarnamn och lösenord}" -d {\"header\":\"StringValue\",\"message\":\"StringValue\",\"sMS\":false}
$URL = "https://connect.maklare.vitec.net/User/Notify/StringValue"
$data = "{`"header`":`"StringValue`",`"message`":`"StringValue`",`"sMS`":false}"
Invoke-WebRequest -Uri $URL -Method POST -Headers @{"Content-Type" = "application/json"; "authorization" = "basic {Base64 kodad användarnamn och lösenord}"} -Body $data
// HttpClientInstance ska deklareras som en singleton
// public static readonly HttpClient HttpClientInstance = new HttpClient {
// BaseAddress = new Uri("https://connect.maklare.vitec.net"),
// DefaultRequestHeaders = {
// Authorization = new AuthenticationHeaderValue("Basic", "{Base64 kodad användarnamn och lösenord}")
// }
// }
var json = "{\"header\":\"StringValue\",\"message\":\"StringValue\",\"sMS\":false}";
using (var response = await HttpClientInstance.PostAsync("User/Notify/StringValue", new StringContent(json, Encoding.UTF8, "application/json"))) {
if (response.StatusCode == HttpStatusCode.Unauthorized) {
// Authorization headern är inte korrekt
}
if (response.StatusCode == HttpStatusCode.Forbidden) {
// Begärt data som det saknas åtkomst till
}
if (response.StatusCode == HttpStatusCode.InternalServerError) {
// Oväntat fel, kontakta Vitec
}
if (response.StatusCode == HttpStatusCode.BadRequest) {
var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<dynamic>(json);
// Hantera valideringsfel, presenteras i resultatet
}
var json = await response.Content.ReadAsStringAsync();
// JsonConvert finns i biblioteket Newtonsoft.Json
var result = JsonConvert.DeserializeObject<dynamic>(json);
// TODO: Gör något med resultatet
}
$URL = "https://connect.maklare.vitec.net/User/Notify/StringValue";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERNAME, "{Användarnamn}");
curl_setopt($ch, CURLOPT_PASSWORD, "{Lösenord}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = "{\"header\":\"StringValue\",\"message\":\"StringValue\",\"sMS\":false}";
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
));
$result = curl_exec($ch);
if (curl_errno($ch)) {
die(curl_getinfo($ch));
}
$info = curl_getinfo($ch);
curl_close($ch);
$http_code = $info["http_code"];
if ($http_code == 401) {
// Användarnamnet eller lösenordet är felaktigt
}
if ($http_code == 403) {
// Begärt data som det saknas åtkomst till
}
if ($http_code == 500) {
// Oväntat fel, kontakta Vitec
}
if ($http_code == 400) {
$json = json_decode($result, true);
// Hantera valideringsfel, presenteras i $json
}
// TODO: Gör något med resultatet
Resultat av begäran
true
<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>