WinHTTPRequest

bhalpin
Member Posts: 309
Hi.
I'm at my wits end. ](*,)
All I want to do is retrieve a page from the web and strore it in a text var, bigtext var, file, - I really don't care.
This is what I have so far:
The Status and StatusText return '200' and 'OK'.
But I have wasted several hours trying to get past this point. I've messed with instreams, outstreams, variants, blobs, - you name it.
Can anyone supply the next few lines?
Thanks' in advance
I'm at my wits end. ](*,)
All I want to do is retrieve a page from the web and strore it in a text var, bigtext var, file, - I really don't care.
This is what I have so far:
// Only var: WinHTTPRequest - Automation - 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest IF NOT ISCLEAR(WinHTTPRequest) THEN CLEAR(WinHTTPRequest); CREATE(WinHTTPRequest); WinHTTPRequest.Open('GET','http://www.mibuso.com',FALSE); WinHTTPRequest.Send; MESSAGE('Status='+FORMAT(WinHTTPRequest.Status())); MESSAGE('StatusText='+WinHTTPRequest.StatusText());
The Status and StatusText return '200' and 'OK'.
But I have wasted several hours trying to get past this point. I've messed with instreams, outstreams, variants, blobs, - you name it.
Can anyone supply the next few lines?
Thanks' in advance
0
Answers
-
check the RESPONSE methode like:
Name DataType Subtype Length WinHttpReq Automation 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest IStream InStream URL Text 250 URL := 'http://www.mibuso.com'; IF ISCLEAR(WinHttpReq) THEN CREATE(WinHttpReq); WinHttpReq.Open('GET',URL,FALSE); WinHttpReq.Send; IF NOT WinHttpReq.WaitForResponse() THEN ERROR('Timed out'); // Alway's displays '200' and 'OK' MESSAGE('Status: '+FORMAT(WinHttpReq.Status())+'\'+ 'StatusText: '+WinHttpReq.StatusText()); IStream := WinHTTPRequest.ResponseStream; WHILE NOT IStream.EOS DO BEGIN //Here do anything like reading the chars in the Stream END;
Also you can search the Forum for WinHTTP
RegardsDo you make it right, it works too!0 -
Thanks! That did it! =D>
For others, reading this, in his code IStream is an InStream variable. You access the text of the page by doing something like this:// InText is a text var WHILE NOT IStream.EOS DO BEGIN //Here do anything like reading the chars in the Stream IStream.READTEXT(InText,128); // reads 128 chars into var InText // Do whatever with InText END;
0 -
You're welcomeDo you make it right, it works too!0
-
Hey Guys,
i have try this in Navision 3.70B and it did'n worki've got the message with the following informations:
This data type is not supported by C / SIDE.
You have access to data of the following data types:
VT_VOID, VT_I2, VT_I4, VT_R4, VT_R8, VT_CY, VT_DATE, VT_BSTR and VT_BOOL
the debugger hold onIStream := WinHTTPRequest.ResponseStream;
thanks for some help0 -
tyr XmlDoc.load(WinHTTP.ResponseBody); if it's an xml file. otherwise you'll need to do exe upgrade0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions