Options

Problem with httpRequest and WinhttpRequest after upgrading

martinjordtmartinjordt Member Posts: 18
edited 2013-03-07 in NAV Three Tier
Hi,

Since upgrading from classic 2009 to 2013 I have a problem with a function used to download data directly from a URL.
The codeunit I have created works with httpRequest using the automation 'Microsoft XML, v6.0'.XMLHTTP60.
The code looks like this:
Timeout := 7000;

CREATE(httpRequest,FALSE,TRUE);
httpRequest.open('GET',Link,FALSE);
TimeBegin := TIME;
httpRequest.send();

REPEAT
  Elapsed := TIME - TimeBegin;
  IF Elapsed >= Timeout THEN BEGIN
    CLEAR(httpRequest);
    EXIT(FALSE)
  END;
UNTIL httpRequest.readyState() = 4;

IF NOT (httpRequest.status = 200) THEN BEGIN
  CLEAR(httpRequest);
  EXIT(FALSE);
END;

IStream := httpRequest.responseStream();    <- Error here!!!!!

CLEAR(httpRequest);
CLEAR(Response);
Response.READ(IStream);

Actually it is ‘borrowed’ from another post here on Mibuso, and has worked very nicely – until upgrading to 2013 
The error I get is the message that NAV cannot convert Microsoft.Dynamics.NAV.Runtime.Automation to Microsoft.Dynamics.NAV.Runtime.NavInstream

I have also tried changing the code utilizing WinHttpRequest instead, but the result is the same.

Any ideas?

Comments

  • Options
    martinjordtmartinjordt Member Posts: 18
    Found a solution to the problem...
    {
    IStream:= httpRequest.responseStream();
    CLEAR(Response);
    Response.READ(IStream);
    }
    
    CLEAR(Response);
    Response.ADDTEXT(httpRequest.responseText);
    
    

    Still would like to know why streaming does not Work in 2013 though :-/
  • Options
    snyktpsnyktp Member Posts: 75
    How about if we need to get image from URL ? We cannot use ADDTEXT. How are we gonna convert the below codes to NAV2013


    mxh.open('GET',Url+"No.",FALSE);
    mxh.send(var_);
    var_ := mxh.responseStream;
    CLEAR(mxh);

    is := var_;
    mbt.READ(is);
    Picture.CREATEOUTSTREAM(os);
    mbt.WRITE(os);
Sign In or Register to comment.