AL0296: The type or method 'Initialize' cannot be used for 'Extension' development.

Hello Everyone

I am getting below error when I am compiling the code in VS code editor

AL0296: The type or method ‘Initialize’ cannot be used for ‘Extension’ development.

AL0296: The type or method ‘SetReturnType’ cannot be used for ‘Extension’ development.

I am using below code in code unit

procedure CallRESTWebService(var Parameters: Record RESTWebServiceArguments): Boolean
var
TempBlob: Record Tempblob temporary;
HttpWebRequestMgt: Codeunit “Http Web Request Mgt.”;
JsonInStream: InStream;

begin
TempBlob.INIT();
TempBlob.Blob.CREATEINSTREAM(JsonInStream);
CLEAR(HttpWebRequestMgt);
HttpWebRequestMgt.Initialize(Parameters.URL);
HttpWebRequestMgt.SetReturnType(‘application/json’);
//HttpWebRequestMgt.SetMethod(‘POST’);
HttpWebRequestMgt.SetReturnType(‘application/json’);
HttpWebRequestMgt.SetContentType(‘application/x-www-form-urlencoded’);
HttpWebRequestMgt.AddHeader(‘Accept-Encoding’, ‘utf-8’);

I am using the below version of VS code editor

Version: 1.33.1 (user setup)
Commit: 51b0b28134d51361cf996d2f0a1c698247aeabd8
Date: 2019-04-11T08:27:14.102Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Windows_NT x64 10.0.17134

App. json

“publisher”: “Default publisher”,
“brief”: “”,
“description”: “”,
“version”: “1.0.0.0”,
“privacyStatement”: “”,
“EULA”: “”,
“help”: “”,
“url”: “”,
“logo”: “”,
“capabilities”: [],
“dependencies”: [],
“showMyCode”: true,
“screenshots”: [],
“platform”: “13.0.0.0”,
“application”: “13.0.0.0”,
“features”: [“TranslationFile”],
“idRange”: {
“from”: 50000,
“to”: 50149
},
“runtime”: “2.1”
}

Am I missing something? any suggestion.

Thanks

Devesh

When you create an AL extension, it is by default targeted to be deployed in the cloud. And this imposes certain limitations - you cannot use internal methods. So, you either have to change the target to “Internal”, or remove any reference to Http Web Request Mgt. codeunit, as nearly all its methods are internal.

You can replace it with HttpClient data type.

https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/httpclient/httpclient-data-type

And about target levels:

https://community.dynamics.com/nav/b/stefanodemiliani/archive/2018/08/14/dynamics-365-business-central-target-levels-in-extensions-development-demystifyed

Thanks Alexander for your response. I will check and update you.