Options

BC API Company reference in url

Dear NAV & BC experts,

i have a Businnes Central 14 implementation, i have a problem when referencing API url exposed by BC. I've configured all OData parameter in sertvice configuration (except Company Default Name).
When is use, for example, an out-of-the-box API such as payment method, in order to retrive all data i use the following URL
http://servername:portId/ServiceName/api/beta/companies(CompanyId)/paymentMethods/

The problem is that in the Company Table, all companies have Id fierld with "id":"00000000-0000-0000-0000-000000000000"
tg0hmmv5ob50.png
Since this environment has been uipgraded from an older version (NAV 2016) probably during upgrade some step have been missed.

In order to resolve this, what do you sugfgest? Is there any way to recalculate ID in Company table?

Thanks all

Best Answer

Answers

  • Options
    DenSterDenSter Member Posts: 8,304
    The API does not refer to the ID field, it refers to the SystemID field. This is a system field, you will not see it in the table designer. The 'ID' field with field number 8000 is obsolete now, don't use it.

    I wrote about this last year (here: http://thedenster.com/use-systemid)
  • Options
    Hello Daniel, thank you for your response, i didn't knwo about new field SystemId, i've read your post on your blog, that is a very useful information.
    But in my case, if i try to inspect pages such customer and company, i don't have any field called Systemid (i don't have neither $system created at, $system created by$ etc). Maybe that is due to the version i am using (Business Central 14, spring 2019 on-premise), can you tell me from whichBC version the field SystemId has been introduced?
  • Options
    DenSterDenSter Member Posts: 8,304
    Oh right, yeah you're right that was probably in a later version. I'd have to look that up, but if that doesn't show up in the page inspector then it's not there (obviously). I didn't start working with the API until then, I'm actually surprised that it would work with that ID field at all. Not sure if there is a process that fills in those ID values, I don't have a v14 environment at the moment

    Have you tried asking on Twitter or in Discord?
  • Options
    AgannaloAgannalo Member Posts: 12
    Answer ✓
    Hello, faced similar issue and finally added "OnAfterInsert" guid value to systemId. As i remember its all becouse of service setup:
    https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/configure-server-instance
    Search for "Integration Records Table (ID)"
  • Options
    Thanks Agannalo, that is somenthing if was looking for. I will to set that configuration on the next upgrade i am going to have

    BR
Sign In or Register to comment.