FUNCTION login lRueck = .F. cToken = "" IF RIGHT(this.cUrl,1) <> "/" this.cURL = this.cUrl + "/" Endif cLoginURL = this.cURL + "login" cContent = "{ " + Chr(34) + "username" + Chr(34) + " : " + Chr(34) + this.cUser + Chr(34) + ", " + Chr(34) + "password" + Chr(34) + " : " + Chr(34) + this.cPasswort + Chr(34) + "}" this.oHTTP = CREATEOBJECT("wwhttp") this.oHTTP.AddPostKey(cContent) this.oHTTP.cExtraHeaders = "content-type:application/json" + CHR(13) + CHR(10) lcHTML = this.oHTTP.HTTPGet(cLoginURL) IF this.oHTTP.cResultcode = "200" lRueck = .T. this.cToken = lcHTML ELSE this.cErrortext = this.oHTTP.cErrorMsg Endif RETURN (lRueck) ENDFUNCThen, for further calls it uses the token for authorisation:
FUNCTION donursuche LPARAMETERS cSuche lRueck = .F. this.oHTTP.cExtraHeaders = "accept:application/json" + CHR(13) + CHR(10) ; + "Authorization:Bearer" + this.cToken + CHR(13) + CHR(10) cSuchurl = this.cUrl + "products?search=" + cSuche + "&size=100" + "&sourde=VLB" cResult = this.oHTTP.HTTPGet(cSuchURL) IF this.oHTTP.cResultcode = "200" lRueck = .T. IF LEN(cResult) > 0 this.cJson = cResult Else this.cErrortext = "Keine Antwort erhalten" Endif ELSE this.cErrortext = this.oHTTP.cErrorMsg Endif RETURN (lRueck) ENDFUNCHave a look at setting the Extraheaders-Property.