Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create HTTP Request object
Message
 
 
À
21/12/2016 19:41:34
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01645753
Message ID:
01645856
Vues:
53
>>>>Hi,
>>>>
>>>>Do you know, and if yes, how, to create an HTTP Request object in VFP?
>>>>
>>>>TIA
>>>
>>>Depending on your plans, you can use the ServerXMLHTTP class.
>>>
>>>
>>>LOCAL HttpRequest AS MSXML2.ServerXMLHTTP60
>>>LOCAL HttpResponseEndPoint AS String
>>>LOCAL Reply AS String
>>>
>>>m.HttpResponseEndPoint = "https://www.levelextreme.com"
>>>
>>>m.HttpRequest = CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")
>>>
>>>m.HttpRequest.Open("GET", m.HttpResponseEndPoint, .F.)
>>>m.HttpRequest.Send()
>>>
>>>m.Reply = m.HttpRequest.Responsetext
>>>
>>>? m.Reply
>>>
>>
>>Your code works, as you wrote it. But I need to take just one line from your code, that creates httpRequest and add parameters to it.
>>
>>
>>m.HttpRequest = CREATEOBJECT("MSXML2.ServerXMLHTTP.6.0")
>>m.HttpRequest.AddParameter("grant_type", "password")
>>
>>
>>The second line above fails. If you know or can see what is wrong with adding a parameter the way I did, please let me know.
>
>To send POSTed data:
>
>
>m.HttpRequest.Open("POST", m.HttpResponseEndPoint, .F.)
>m.HttpRequest.Send("grant_type=password")
>
>
>To set request headers:
>
>
>m.HttpRequest.SetRequestHeader("HeaderName", "HeaderValue")
>
I am trying to GET some data from the server. And using your code (above with the Open("GET")) I don't get anything returned by the .Send() method. Should the .Send() return something? Or what am I missing?

Thank you.

UPDATE. I see where I need to get the returned string. It is on this line:
m.Reply = m.HttpRequest.Responsetext
I am getting Authorization Denied message. So something is wrong but not with your code. Thank you.
"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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform