AL icon indicating copy to clipboard operation
AL copied to clipboard

Problem with "PageType = API" - not working?

Open megel opened this issue 7 years ago • 12 comments

I have tried to create an API page like:

page 50102 MyInfo
{
    PageType       = API;
    EntityName     = 'myInfo';
    EntitySetName  = 'myInfos';
    APIVersion     = 'beta';
    SourceTable    = "My Infos";
    ODataKeyFields = "Id";
    layout
    {
        area(content)
        {
            field("Id"; Id) {}
            field("Item No.";"Item No.") {}
            field("Item Id";"Item Id") {}            
        }
    }
}

I have also tried to extend an existing API page e.g. Customer Entity

pageextension 50101 "Customer Entity Ext" extends "Customer Entity"
{
    layout
    {
        addlast(content)
        {
            field("myData"; 'sss') { ApplicationArea = All; }            
        }
    }
}

My NAV Version is: grafik I have enabled the API in CustomSettings.config:

  <!-- Specifies whether the API web services are enabled. -->
  <add key="ApiServicesEnabled" value="true" />

The new API-Page was not present, when I have tried to query by Postman with URL: ....azure.com:7048/NAV/api/beta/myInfos/

The existing API-Page (Customer Entity) did not contain the new Field.

{
    "@odata.context": "....azure.com:7048/NAV/api/beta/$metadata#customers",
    "value": [
        {
            "@odata.etag": "W/\"JzM2O0VnQUFBQUo3Q0RRQU5nQTRBRGtBTndBNEFEZ0FPUUFBQUFBQTY7MzE3ODU5MDsn\"",
            "id": "14cad1e0-db33-418f-a14a-00a4bf4623aa",
            "number": "46897889",
            "displayName": "Englunds Kontorsmöbler AB",
            "type": "Company",
            "phoneNumber": "",
            "email": "",
            "website": "",
            "taxLiable": false,
            "taxAreaId": "7eba3574-f889-49c0-876b-7c416f552c6f",
            "taxAreaDisplayName": "Debitoren und Kreditoren in EU",
            "taxRegistrationNumber": "777777777701",
            "currencyId": "0685ebce-5c90-4786-82d3-da6f206b7df5",
            "currencyCode": "SEK",
            "paymentTermsId": "487c7f01-7d6f-4764-af77-5d07ed7ee392",
            "shipmentMethodId": "093a2f3a-c4a8-488e-aac4-7f3050cc0ecc",
            "paymentMethodId": "00000000-0000-0000-0000-000000000000",
            "blocked": " ",
            "balance": 1043.55,
            "overdueAmount": 0,
            "totalSalesExcludingTax": 0,
            "lastModifiedDateTime": "2017-11-23T02:12:37.593Z",
            "address": {
                "street": "Kungsgatan 18",
                "city": "Norrköping",
                "state": "",
                "countryLetterCode": "SE",
                "postalCode": "600 03"
            },
            "paymentTerms": {
                "code": "LM",
                "description": "Laufender Monat"
            },
            "shipmentMethod": {
                "code": "EXW",
                "description": "Ab Warenhaus"
            },
            "paymentMethod": null
        }
   ]
}```
Where is my fault?

megel avatar Dec 21 '17 17:12 megel

Hi @megel ! We will look into this and see where the issue lies.

atoader avatar Dec 28 '17 09:12 atoader

My issue below is closed. See following comment.

This is by design right now, one can add on-prem (C/SIDE), but extension support require namespacing which we are working on now. If allowed as-is, all extensions would publish to the root API. Update expected in the next couple of updates after Tenerife.

Any update on this? I have created a new API page as an object which works fine - but when I convert to AL and publish as an extension the 'testapiintegration' API page is not seen.

page 50001 "Test API Integration" { Caption = 'testapiintegration', Locked=true; EntityName = 'testapiintegration'; EntitySetName = 'testapiintegration'; PageType = API; SourceTable = "Test API Integration"; layout { area(content) { repeater(Group) { field("Function App URL";"Function App URL") { } field("Web App URL";"Web App URL") { } field("Azure Function App Key";"Azure Function App Key") { } } } }

}

TimothyWatkins avatar Mar 05 '18 22:03 TimothyWatkins

This is work in progress and should be available in Dev Preview in the next few weeks.

StanislawStempin avatar May 25 '18 14:05 StanislawStempin

Which #Docker tag should I use?

megel avatar May 25 '18 14:05 megel

These two blog posts should have all the information you need: https://blogs.msdn.microsoft.com/freddyk/2018/04/16/which-docker-image-is-the-right-for-you/ https://blogs.msdn.microsoft.com/nav/2018/05/03/al-developer-previews-multiple-releases-and-github/

StanislawStempin avatar May 25 '18 14:05 StanislawStempin

Any update when we can have custom API support in Business Central?

jatinmittal1822 avatar Sep 20 '18 12:09 jatinmittal1822

Custom API's should be working and have done so for a while. From my previous post, our API(s) has now been updated to look as below, note the new properties. Use an up to date VSIX compiler, preferably 2.0 or higher.

page 50001 "Test API Integration"
{
    Caption = 'testapiintegration';
    PageType = API;
    DelayedInsert = true;
    EntityName = 'testapiintegration';
    EntitySetName = 'testapiintegration';
    APIVersion = 'v1.0';
    APIGroup = 'someapiGroup';
    APIPublisher = 'someApiPubnlisher';

    SourceTable = "Test API Integration";

    layout
    {
        area(content)
        {
            repeater(Control3)
            {
                ShowCaption = false;
                field(functionAppURL; "Function App URL")
                {
                    Caption = 'functionAppURL';
                }
                field(webAppURL; "Web App URL")
                {
                    Caption = 'webAppURL';
                }
                field(functionAppKey; "Function App Key")
                {
                    Caption = 'functionAppKey';
                    ExtendedDatatype = Masked;
                }
            }
        }
    }
    trigger OnOpenPage()
    begin
        RESET();
        if not Get() then begin
            INIT();
            INSERT();
        end;
    end;
}

TimothyWatkins avatar Sep 20 '18 12:09 TimothyWatkins

Yes new version works pretty well. I have used in a new object last week. But I didn't try to extend an existing API object.

megel avatar Sep 20 '18 17:09 megel

@megel On which Business Central version you have API working?

I am using Business Central RC1 On-Premises US Dynamics NAV 13.0 (24285), but can't get custom API in list of API via Postman.

AL Language compiler version 2.0.42188

jatinmittal1822 avatar Sep 21 '18 07:09 jatinmittal1822

@jatinmittal1822 I have used for my demo RC2 and VS Code to call the API Use RESTClient as extension for VS Code:

I create a file api.http and called my API:

### GET all Entities
GET https://MY-BUSINESS-CENTRAL-URL.cloudapp.azure.com:7048/nav/api/API-PUBLISHER/API-GROUP/API-VERSION/companies(6b8c92a5-5d63-49ab-bb1b-5aa7fba47f0b)/ENTITIES-NAME
Content-Type: application/x-www-form-urlencoded
Authorization: Basic BC-USERNAME BC-WEBSERVICE-ACCESS-TOKEN

megel avatar Sep 24 '18 10:09 megel

@megel Thanks for your reply. It is working for me now.

It's an issue of URL, I am not aware of using API-PUBLISHER/API-GROUP/API-VERSION in custom API.

jatinmittal1822 avatar Sep 24 '18 11:09 jatinmittal1822

It was also my fault :) as I started

megel avatar Sep 24 '18 11:09 megel

Closing as this old entry seems to have been resolved

pborring avatar Dec 05 '23 12:12 pborring