Showing posts with label Business Central. Show all posts
Showing posts with label Business Central. Show all posts

Wednesday, December 30, 2020

Test custom page type api on postman

Today we see how to test the custom page type API on postman.

Step 1: Open postman set the request type GET, paste API url, set authorization type Basic Auth, add user name and password.













Step 2: search the users and open the form











Step 3: copy the username and web service access key and paste it is Postman Authorization.














Step 4: Now click on send button you can see result.





How to create Custom page type API Business central

Today we see how to make custom API in business central.

I ma making API for Item data.


Step 1: 

add new file in project and set the any name.al Write the below code in the file.

page 50103 Products
{
    PageType = Card;
    SourceTable = Item;

    layout
    {
        area(Content)
        {
            group(GroupName)
            {
                field("No."; Rec."No."{ }

                field(Description; Rec.Description{ }
                field(Blocked; Rec.Blocked{ }
                field(Type; Rec.Type) { }
                field("Base Unit of Measure"; Rec."Base Unit of Measure"{ }
                field("Last Date Modified"; Rec."Last Date Modified"{ }
            }
        }
    }
}


Step 2: Add new file in the project and set the name.xml. In file write twebservices and click enter you will automatically get the structure.

<?xml version="1.0" encoding="UTF-8"?>
<ExportedData>
    <TenantWebServiceCollection>
        <TenantWebService>
            <ObjectType>Page</ObjectType>
            <ServiceName>Products</ServiceName>
            <ObjectID>50103</ObjectID>
            <Published>true</Published>
        </TenantWebService>
    </TenantWebServiceCollection> 
</ExportedData>


Step 3: Now run the project it automatically publish your api.

Step 4: Search web service in business central search bar and click on it.



Step 5: You can see the webservice in the below image.



In the next post we will look at how we use our API on postman.