Error while sending URL via HTTP POST using XMLHTTP

zeonzeon Member Posts: 130
Hi,

I'm trying to post an url via http post using xmlhttp. The url contains customer, delivery and item information. As this url can be very long I have created a text array of urls. Url is datatype Text and of length 1024 with five dimensions. The problem arises when I try to send the url:
CLEAR(HTTPreq); //HTTPreq = Automation 'Microsoft XML, v6.0'.XMLHTTP'Microsoft XML, v6.0'.XMLHTTP
CREATE(HTTPreq,TRUE);
HTTPreq.open('POST',URL[1]+URL[2]+URL[3]+URL[4]+URL[5], FALSE);
HTTPreq.setRequestHeader('Content-type','text/xml');
HTTPreq.send(URL[1]+URL[2]+URL[3]+URL[4]+URL[5]);

When the combined length of URL[1]+URL[2]+URL[3]+URL[4]+URL[5] exceeds 2044 characters I receive the following error:

"There is not sufficient available space in the C/AL stack memory to execute the task".

"There are too many simultaneous activities, due to the way recursive function call is used in the program. The problem can be solved temporarily by shutting down some of the open activities (but the function still cannot be executed)."


If I send 2043 characters it will be succesful.

The above code is placed in a codeunit and is called from a report which also generates an Excel document. In the OnPostReport trigger of the report I have a repeat-until construct which calls this codeunit to send an url with info to another web system. There is no recursive calls. Btw I can call the above codeunit more than 100 times with an URL shorterthan 2044 characters, and it will succeed. But if I call it once with an url that exceeds 2044 characters it will fail. ](*,)

Any ideas what could be wrong or ideas for an alternative solution?

I'm running this on Attain 3.70.

Answers

  • rmv_RUrmv_RU Member Posts: 119
    Try to use variant datatype.
    Name	DataType	Subtype	Length
    xmlTextNode	Automation	'Microsoft XML, v6.0'.IXMLDOMText	
    xmlTextNode.appendData(url[1]);
    xmlTextNode.appendData(url[2]);
    xmlTextNode.appendData(url[3]);
    xmlTextNode.appendData(url[4]);
    xmlTextNode.appendData(url[5]);
    HTTPreq.send(xmlTextNode.nodeValue);
    
    Looking for part-time work.
    Nav, T-SQL.
  • zeonzeon Member Posts: 130
    Thanks for your input. I have tried it, but gets the following error :-(

    I thought that it is correctly installed as I use 'Microsoft XML, v6.0'.XMLHTTP'Microsoft XML, v6.0'.XMLHTTP to create the http request?

    Any ideas?
  • rmv_RUrmv_RU Member Posts: 119
    zeon wrote:
    Thanks for your input. I have tried it, but gets the following error :-(

    I thought that it is correctly installed as I use 'Microsoft XML, v6.0'.XMLHTTP'Microsoft XML, v6.0'.XMLHTTP to create the http request?

    Any ideas?

    You must create XML Document first.
    Name	DataType	Subtype	Length
    xmlDoc	Automation	'Microsoft XML, v6.0'.DOMDocument	
    CREATE(xmlDoc);
    xmlTextNode := xmlDoc.createTextNode('');
    
    Looking for part-time work.
    Nav, T-SQL.
  • zeonzeon Member Posts: 130
    That worked! Oh man, you just saved my day! Huge thanks! \:D/

    /zeon
Sign In or Register to comment.