Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
REST web service
Message
From
02/01/2019 10:00:27
 
 
To
02/01/2019 09:30:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
Application:
Desktop
Miscellaneous
Thread ID:
01663216
Message ID:
01665051
Views:
91
Likes (2)
>>>Hello all,
>>>
>>>Can you provide free code so I can access a REST web service. I searched a bit and found out about Chilkat or West Wind but those are not free.
>>>
>>>I am using TwilioX and it works great. I guess that LibCurl could be used to access a web Service? Can anybody tell me how I could access a REST web service this way?
>>
>>Hi,
>>
>>COM object WinHttp.WinHttpRequest.5.1 is your friend.
>>REST API are HTTP GET and POST requirements.
>>
>>MartinaJ
>
>Hello Martina,
>
>I am trying to use this COM Object to test a webservice, thinking I should use something like GetResponse(). However it does not exist a method like that, only GetResponseHeader(), which is not what I would have expected.
>
>What I did so far, but without success, is to get a list as in this example:
>https://api.predic8.de/shop/products/
>
>So I tried it like the following:
>
>req = CreateObject("WinHttp.WinHttpResponse.5.1")
>req.Open("POST", "https://api.predic8.de/shop/products/", .F.)
>req.SetRequestHeader("Content-type", "application/x-www-form-urlencoded")
>MESSAGEBOX(req.Send())
>MESSAGEBOX(req.ResponseText)
>
>
>Send() returns null, ResponseText contains an error, because it expected data to be sent. So I wonder if this is the complete wrong approach, or I am trying with the wrong api, or i am missing something?

Christian

You should Get, instead of Post. The content-type is a bit irrelevant, since you're not sending anything, but considering you're talking to a JSON endpoint, setting it to "application/json" would be more adequate, probably.

To read the data, check Marco Plaza's JSON functions at VFPX, they can populate an object or a cursor with the downloaded list.
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform