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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

I have a problem that I hope you can help me solve (Read Json File in AL)

(1) ShareShare
ReportReport
Posted on by 4
Hi,,
I have a problem that I hope you can help me solve Read Json File in AL
Error in Postman:
 
Token PASS :
 
 
 
Web Services:
 
 
AL Code : 
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
codeunit 50137 "ReadJSONCode"
{
    [ServiceEnabled]
    [Scope('Cloud')]
    procedure ReadJsonTest(JsonObjectText: Text)
    var
        Customer: Record Customer;
        JSONManagement: Codeunit "JSON Management";
        ObjectJSONManagement: Codeunit "JSON Management";
        CodeText: Text;
        CustomerJsonObject: Text;
    begin
        JSONManagement.InitializeObject(JsonObjectText);
        if JSONManagement.GetArrayPropertyValueAsStringByName('Customer', CustomerJsonObject) then begin
            ObjectJSONManagement.InitializeObject(CustomerJsonObject);
 
            Customer.Init();
            ObjectJSONManagement.GetStringPropertyValueByName('No', CodeText);
            Customer.Validate("No.", CopyStr(CodeText.ToUpper(), 1, MaxStrLen(Customer."No.")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Name', CodeText);
            Customer.Validate("Name", CopyStr(CodeText, 1, MaxStrLen(Customer."Name")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Address', CodeText);
            Customer.Validate("Address", CopyStr(CodeText, 1, MaxStrLen(Customer."Address")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Address_2', CodeText);
            Customer.Validate("Address 2", CopyStr(CodeText, 1, MaxStrLen(Customer."Address 2")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('City', CodeText);
            Customer.Validate("City", CopyStr(CodeText, 1, MaxStrLen(Customer.City)));
 
            ObjectJSONManagement.GetStringPropertyValueByName('County', CodeText);
            Customer.Validate("County", CopyStr(CodeText, 1, MaxStrLen(Customer.County)));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Country_Region', CodeText);
            Customer.Validate("Country/Region Code", CopyStr(CodeText, 1, MaxStrLen(Customer."Country/Region Code")));
 
            ObjectJSONManagement.GetStringPropertyValueByName('Post_Code', CodeText);
            Customer.Validate("Post Code", CopyStr(CodeText, 1, MaxStrLen(Customer."Post Code")));
 
            Customer.Insert();
 
        end;
    end;
}
I have the same question (0)
  • Gerardo Rentería García Profile Picture
    27,507 Most Valuable Professional on at
  • Suggested answer
    YUN ZHU Profile Picture
    102,516 Super User 2026 Season 1 on at
    Hi, try the following code, I have tested it before and it works without problems.
     
    Thanks.
    ZHU

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 June Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 677 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 521 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 306 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans