web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Unanswered

Can anyone help me on this issue. I am facing this issue "Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized"

(0) ShareShare
ReportReport
Posted on by 10

Hi Community,


Can anyone help me on below issue.
When i'm trying to read the data from the D365 standard Rest API response getting the below error "Microsoft.Dynamics.Nav.Runtime.NavHttpContent variable not initialized."
Below is the code i'm using :

var
        client: HttpClient;
        Content: HttpContent;
        gHeaders: HttpHeaders;
        lHeaders: HttpHeaders;
        Request: HttpRequestMessage;
        Response: HttpResponseMessage;
        Url: Text;
        APIKey: Text;
        RString: Text;
        lText: Text;
        ResHeaders: HttpHeaders;
        ResContent: HttpContent;
Begin 
lText := 'scope=APIServices&grant_type=client_credentials';
Content.Clear();

        Content.WriteFrom(lText);
        Request.SetRequestUri(Url);
        gHeaders.Clear();
        lHeaders.Clear();

        Content.GetHeaders(lHeaders);
        lHeaders.Remove('Content-Type');
        lHeaders.Add('Content-Type', 'application/x-www-form-urlencoded');
        Content.GetHeaders(lHeaders);

        Request.GetHeaders(gHeaders);
        gHeaders.add('accept', 'application/Json');
        gHeaders.add('authorization', APIKey);
        Request.Content(Content);
        Request.GetHeaders(gHeaders);
        Request.Method := 'get';
   
        IF client.Send(Request, Response) THEN
            IF NOT Response.IsSuccessStatusCode THEN
                Error('Web service returned error:\\' + 'Status code: %1\' + 'Description: %2',
                        Response.HttpStatusCode(), Response.ReasonPhrase());

        Response.Content().ReadAs(RString);
        JsonReadWrite.ReadJSonToJSonBuffer(RString, JsonBuffer);
END;

Getting the error at this line : Response.Content().ReadAs(RString);

  • Greg Kujawa Profile Picture
    841 on at

    Do you have Allow HttpClient Requests defined in your extension?

  • Shahzaib Nazim Profile Picture
    10 on at

    Yes, I have already Allow HttpClient Request in the extension.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 743 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 546 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 332 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans