Dokumentation för API-funktioner
PUT CRM/Economy/{customerId}/Estate/{estateId}/operatingCosts Uppdatera driftkostnader på ett objekt Request Information URI Parameters
NamnBeskrivningTypInformation
customerId Kundid string Krävs
estateId bostadsid string Krävs
Body Parameters driftskostnader Operation
NamnBeskrivningTypInformation
Heating Uppvärmningskostnad integer

Electricity Elkostnad integer

WaterAndDrain Kostnad för vatten och avlopp integer

ChimneySweeping Sotningsavgift integer

RoadCommunity Kostnad för vägsamfällighet integer

Sanitation Renhållningsavgift integer

Insurance Försäkring integer

Other Övrigt integer

PersonsInHousehold Antal personer i hushållet integer

Comment Kommentar string

Request Formats

{
  "heating": 1,
  "electricity": 1,
  "waterAndDrain": 1,
  "chimneySweeping": 1,
  "roadCommunity": 1,
  "sanitation": 1,
  "insurance": 1,
  "other": 1,
  "personsInHousehold": 1,
  "comment": "sample string 2"
}
<Operation xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Vitec.Housing.Connect.Api.Models.Economy">
  <ChimneySweeping>1</ChimneySweeping>
  <Comment>sample string 2</Comment>
  <Electricity>1</Electricity>
  <Heating>1</Heating>
  <Insurance>1</Insurance>
  <Other>1</Other>
  <PersonsInHousehold>1</PersonsInHousehold>
  <RoadCommunity>1</RoadCommunity>
  <Sanitation>1</Sanitation>
  <WaterAndDrain>1</WaterAndDrain>
</Operation>
Response Information Resource Description Uppdatera driftkostnader på ett objekt string Kodexempel

curl "https://connect.maklare.vitec.net/CRM/Economy/StringValue/Estate/StringValue/operatingCosts" -X PUT -H "Content-Type: application/json" -H "Authorization: basic {Base64 kodad användarnamn och lösenord}" -d {\"heating\":0,\"electricity\":0,\"waterAndDrain\":0}
            

$URL = "https://connect.maklare.vitec.net/CRM/Economy/StringValue/Estate/StringValue/operatingCosts"
$data = "{`"heating`":0,`"electricity`":0,`"waterAndDrain`":0}"
Invoke-WebRequest -Uri $URL -Method PUT -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 = "{\"heating\":0,\"electricity\":0,\"waterAndDrain\":0}";
using (var response = await HttpClientInstance.PutAsync("CRM/Economy/StringValue/Estate/StringValue/operatingCosts", 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/CRM/Economy/StringValue/Estate/StringValue/operatingCosts";

$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 = "{\"heating\":0,\"electricity\":0,\"waterAndDrain\":0}";
$headers = array( "Content-Type: application/json", "Content-Length: " . strlen($data) );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');

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
Testformulär Text input
Response Formats
"sample string 1"
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">sample string 1</string>