====== 4.3 Pisanje podataka s VBA ====== Kreiranje, izmjena i brisanje zapisa. ===== Umetanje novog zapisa ===== Sub NoviKlijent() Dim http As Object Dim url As String Dim body As String url = "http://localhost:5000/api/v1/dsn/demo/tables/Customers" body = "{""Name"":""Nova Firma d.o.o."",""Country"":""Croatia""}" Set http = CreateObject("MSXML2.XMLHTTP") http.Open "POST", url, False http.setRequestHeader "Content-Type", "application/json" http.send body If http.Status = 200 Then MsgBox "Uspješno kreirano!" Else MsgBox "Greška: " & http.responseText End If End Sub ===== Ažuriranje zapisa ===== Sub AzurirajKlijenta() Dim body As String body = "{""primaryKey"":{""Id"":42},""fields"":{""Name"":""Ažurirano""}}" http.Open "PUT", url, False http.setRequestHeader "Content-Type", "application/json" http.send body End Sub ===== Brisanje zapisa ===== Sub ObrisiKlijenta() http.Open "DELETE", url & "?Id=42", False http.send End Sub