[jawsscripts] Re: Rest API

  • From: Jim Bauer <holdsworthfan@xxxxxx>
  • To: jawsscripts@xxxxxxxxxxxxx
  • Date: Sun, 6 Dec 2020 19:10:10 -0600

A toy example using GET and XMLHTTPRequest[*]. NOTE(s): This may not compile (I 
tested this in the BX COM map and am translating the steps into code). In 
theory this handles post data, but I didn't try that.


var object oRequest = createObjectEx("Msxml2.XMLHTTP.6.0", True) ; createObject 
with CoCreateInstance
oRequest.open("GET", 
"https://official-joke-api.appspot.com/jokes/programming/random", False) ; call 
is not async (will block)
oRequest.send()
copyToClipboard(oRequest.responseText)

string (87 chars): '[{"id":27,"type":"programming","setup":"['hip', 
'hip']","punchline":"(hip hip array)"}]'

You should also be able to use responseXML and get an XML DOM object you could 
manipulate with xpath.

[*] 
https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms759148(v=vs.85)

HTH

On 12/5/2020 5:15 PM, Bob wrote:

Weird one. 
I’d like to grab some external data for use in a script from a rest api. 

Has anyone done this before or can think of a way to create and submit the 
post data and get a result back?

Thanks

Bob
__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts


__________�

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: