Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
REST web service
Message
From
02/01/2019 10:12:57
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
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:
01665053
Views:
67
Likes (1)
>>>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?

Try it with GET. ie:
clear
Local loXmlHttp As "Microsoft.XMLHTTP", lcUrl
lcUrl = "https://api.predic8.de/shop/products/"

loXmlHttp = Newobject( "Microsoft.XMLHTTP" )
loXmlHttp.Open( "GET" , m.lcUrl, .F. )
loXmlHttp.Send( )


? loXmlHttp.Status
? loXmlHttp.responsetext
? "==================================="
PS: I would however suggest creating and using a C# based wrapper. It is very hard to write especially POST in VFP.
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform