Hi all,

I try to use the streaming API to get whole items in MIME encoding.

I'm quite sure that I've constructed the right url:
http://172.16.133.10:7191/attachment....1.50.1&mime=1
the session id is the same I got back from the login call and that I was
using to request some messages (readCursor) to get a messageID.

I always get back:
<HTML><BODY><H1>401 Authorization Required</H1></BODY></HTML>

Any ideas ?

Or do I have to be logged in as a trusted application ?

Thanks

Rainer

Bye the way that piece of code looks like:

var item : TGWItem;
messid : string;
begin
if LBMess.ItemIndex >= 0
then begin
item := items.gwitem[LBMess.ItemIndex];
messID := item.Values['id'];

if pos('@', messid) > 0 then messID := copy(messID,1,
pos('@',messid) - 1);
gwsession.DoStreamRequest(messID,'mime=1');
Memo1.Lines.LoadFromStream(GWSession.StreamDoc);
end;
end;

Yes, this is PASCAL !
LBmess is a ListBox (GUI) that is in parallel to the Items -list. LBMess
is filled during login:




var
loginRes : TGWLoginResponse;
i : integer;
retDT, backDT, targetDT : TDateTime;
filter,sfilter, timefilter, sourcefilter : TGWFilter;
gwcursor, foldername, messID : string;

begin
GWSession.SOAPHost:= POAAddr.Text;
GWSession.SOAPPort:= strtoint(POAPort.text);
loginRes := TGWLoginResponse.create;
trystrtodate ('01'+DateSeparator+'01'+DateSeparator+'1970' , retDT );

if uname.Text <> ''
then begin
memo1.clear;
if GWSession.loginUser ( uname.Text, UPwd.Text, loginRes )
then begin
LBMess.Clear;
TargetDT := loginRes.serverUTCTime;
filter := TGWFilter.create;

sfilter := filter.AddFilterGroup('and');
sourcefilter := sfilter.AddFilterGroup('or');
sourcefilter.AddFilterEntry ('source','eq','received');
sourcefilter.AddFilterEntry ('source','eq','sent');
timefilter := sfilter.AddFilterGroup('and');
sfilter.AddFilterEntry('delivered', 'lte', DTimeToXML (TargetDT));
sfilter.AddFilterEntry('delivered', 'gt', DTimeToXML ( retDT ));

GWSession.createCursor ( 'folders', 'default', filter ,gwcursor);

items.clear;

GWSession.readCursor ( gwcursor, 'folders', 'start', true, 200,
items );

for i := 0 to items.Count-1
do lbmess.Items.Add(items.gwitem[i].Values['subject']);

GWSession.destroyCursor( 'folders', gwcursor );

end
else Memo1.Lines.Add('Error logging in '+GWSession.ErrorText);
end;
end;


DoStreamRequest looks like:
function TGWSoapSession.DoStreamRequest (id : string; option : string )
: boolean;
var url : string;
p : integer;
begin
p := pos('soap', FSOAPURL );
url := copy (FSOAPURL, 1,p-1) + 'attachment?session='+fsession+'&id='+id;
if option <> ''
then url := url + '&'+option;
dbwrite ('StreamURL = '+ url );
result := FHttpCon.HTTPMethod('GET', url );
end;