Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create HTTP Request object
Message
 
 
To
22/12/2016 09:19:38
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01645753
Message ID:
01645894
Views:
45
>>>>>
>>>>>Ok, I see two potential issues here: a) extraction of the correct value of the token from the JSON reply; b) the header may require some kind of encoding (base64, for instance). Can you paste here the C# code, with any sensitive information properly redacted?
>>>>
>>>>This is the C# code that works:
>>>>
>>>>var request = new RestRequest('\methodtogettable', Method.GET);
>>>>request.AddHeader("Authorization", "bearer " + _token);
>>>>var response = _client.Execute(request);
>>>>
>>>>
>>>>And I am communicating with the Web API developer over email and he didn't mention need for encoding at all.
>>>
>>>How is your VFP code to get the authorization token?
>>>
>>>By the way: 401 = Unauthorized...
>>
>>Here is the VFP code that get the authorization token (and it works since I can see the value in the debugger):
>>
>>
>>loUser = newObject('wwHTTP', 'wwHTTP.prg')
>>loUser.addPostKey('grant_type', 'password')
>>loUser.addPostKey('username', '1222')
>>loUser.addPostKey('password', 'GDF')
>>
>>cToken = loUser.httppost("http://www.sitename.com/webapi/token")
>>
>>
>>I also just checked the value of the header passed on the GET call in Fiddler and the Header security value is there complete.
>
>You said the response was in JSON format, so how do you extract the actual token from the JSON reply? In your code, isn't cToken being assigned the full reply, and not just the token?

I think you hit the nail on the head. This is probably my mistake as I pass the entire JSON to the header and I need to extract the token. 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
Previous
Reply
Map
View

Click here to load this message in the networking platform