>>>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