How to call Web Service (GET/POST) from MS Dynamics NAV C/AL
//Get
url := 'https://httpbin.org/ip';
CREATE(WinHttp);
WinHttp.Open('GET',url,FALSE);
WinHttp.Send(JsonTxt);
JsonTxt := WinHttp.ResponseText;
MESSAGE(FORMAT(JsonTxt));
//Post
url := 'https://reqbin.com/echo/post/json';
CREATE(WinHttp);
WinHttp.Open('POST',url,FALSE);
WinHttp.SetRequestHeader('Content-Type', 'application/json');
CREATE(XMLDoc);
NodeText := XMLDoc.createTextNode('');
NodeText.appendData('{ "Id": 78912');
NodeText.appendData( '"Customer": "Jason Sweet",');
NodeText.appendData('"Quantity": 1,');
NodeText.appendData( '"Price": 18.00}');
WinHttp.Send(NodeText.nodeValue);
JsonTxt := WinHttp.ResponseText;
MESSAGE(FORMAT(JsonTxt));
Name |
DataType |
Subtype |
Length |
ResponseStream |
InStream |
|
|
ResponseBuffer |
BigText |
|
|
url |
Text |
|
1024 |
JsonTxt |
Text |
|
1024 |
WinHttp |
Automation |
'Microsoft WinHTTP Services, version
5.1'.WinHttpRequest |
|
NodeText |
Automation |
'Microsoft XML, v3.0'.IXMLDOMText |
|
XMLDoc |
Automation |
'Microsoft XML, v3.0'.DOMDocument |
|
Comments
Post a Comment