Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create HTTP Request object
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01645753
Message ID:
01645886
Views:
38
>Hi Dmitri,
>
>this sounds like a REST-Service like I have used in my application so here a two methods of a class I have written. It uses wwipstuff, but the newer westwind client tools will do the same.
>
>This is as method using POST to get a token.
>
>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)
>ENDFUNC
>
>
>Then, 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)    
>ENDFUNC
>
>
>Have a look at setting the Extraheaders-Property.
>
>Best regards
>
>Thomas

My question/concern is about the Extraheaders property. If the Web API does not "know" anything about this property but rather looks at the "standard" header property, this could be the cause of the problem. This is why I am trying to find out what is the name of the "standard" header property of the oHttp object. Does it make sense?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform