Wenn Du Blotato per VBA aus Access ansteuern willst, brauchst Du:
- eine HTTP-Anfrage-Funktion in VBA
- den API-Endpunkt von Blotato
- einen API-SchlĂŒssel (vermutlich in den Einstellungen von blotato.com)
- und ein wenig JSON-Verarbeitung
Voraussetzungen
Access kann keine https-Aufrufe direkt aus VBA ohne Zusatzkomponenten. Du brauchst:
- Entweder: Microsoft XML (MSXML2.XMLHTTP60) fĂŒr HTTP-Requests
- Und: Scripting.Dictionary oder selbstgebautes JSON (optional mit externem JSON-Parser wie
VBA-JSON)
Beispiel: POST-Request an die Blotato-API (Textgenerierung)
Dieser Code ist ein generisches Muster, Du musst die URL, Header und Parameter je nach API-Dokumentation von Blotato anpassen.
Public Sub BlotatoTextGenerieren()
Dim http As Object
Dim url As String
Dim apiKey As String
Dim payload As String
Dim response As String
url = "https://api.blotato.com/v1/text" ' Beispiel-Endpunkt
apiKey = "DEIN_API_KEY_HIER"
' Beispiel-Payload - muss ggf. angepasst werden
payload = "{""prompt"":""Schreibe einen VBA-Code fĂŒr Access"", ""max_tokens"":100}"
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "POST", url, False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer " & apiKey
http.Send payload
If http.Status = 200 Then
response = http.responseText
MsgBox "Antwort von Blotato:" & vbCrLf & response
Else
MsgBox "Fehler: " & http.Status & " - " & http.statusText
End If
End Sub
Hinweise
- Die API-Dokumentation findest Du i. d. R. unter
https://www.blotato.com/docsoder nach Login bei den API-Settings. - Die
responseTextist ein JSON-String – den musst Du ggf. mit einem Parser zerlegen (z. B. VBA-JSON). - Wenn Du Bilder generieren willst, brauchst Du stattdessen einen Image-Endpunkt und musst Base64 oder Image-URLs zurĂŒckverarbeiten.
Optional: JSON auswerten (mit VBA-JSON)
Falls Du aus der Antwort das Textfeld parsen willst:
Dim json As Object
Set json = JsonConverter.ParseJson(http.responseText)
MsgBox json("text")
Zusammenfassung
| Baustein | Beschreibung |
|---|---|
| HTTP-Client | MSXML2.XMLHTTP oder WinHttp.WinHttpRequest |
| Format | JSON, UTF-8 |
| Authentifizierung | Bearer-Token im Header |
| Antwort | JSON, evtl. mit „text“ oder „image_url“ |