Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert C# code to VFP
Message
From
21/12/2016 08:45:58
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Convert C# code to VFP
Miscellaneous
Thread ID:
01645749
Message ID:
01645749
Views:
65
Hi,

I am converting C# code, WinForms, to VFP 9. The purpose of the code is to call POST method of REST from VFP.

Here is the general description of what this code does (by the author of the REST):
For authentication you have to execute POST "http://www.sitename.com/api/token" url with the body having the following format: 
username=5000&grant_type=password&password=ABC123
You'll get a response having "access_token" property in it. This token should be passed in every authenticated 
request in header like this: Authorization: bearer [access_token here]
This is the code the author is using (that authenticates the user) in WinForms:
var request = new RestRequest("/token", Method.POST);

request.AddParameter("grant_type", "password");
request.AddParameter("username", textBoxUserName.Text);    
request.AddParameter("password", textBoxPassword.Text);
            
var response = _client.Execute<AuthResponse>(request);
In VFP I am trying to use the West Wind Client Tool, specifically the class wwjSonServiceClient. The sample code in VFP is as follows:
loProxy = CREATEOBJECT("wwJsonServiceClient")
oAlbums = loProxy.CallService("http://albumviewerswf.west-wind.com/api/albums","","GET")
I believe that when I call the CallService instead of "GET" I will have "POST". But I need to pass the 'request' object in the place of the empty string (above "") (right?). And I don't know how to create such a 'request' object in VFP.

TIA for any suggestions.
"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
Next
Reply
Map
View

Click here to load this message in the networking platform