How to make a simple API call with a json reply in Business Central

Поділитися
Вставка
  • Опубліковано 2 гру 2024
  • Find ipify here: www.ipify.org/
    In/Out/Read/Write • In/Out/Read/Write, Con...
    Find more information at my blog https:/www.hougaard.com or follow me on / ehougaard

КОМЕНТАРІ • 55

  • @a_stray_dog
    @a_stray_dog Рік тому

    2:40 "Now it's working like... Butterrrrrrr."
    Never change, Erik.

  • @KasimNaqvi13
    @KasimNaqvi13 Рік тому +1

    00:03 Learn how to make a simple API call in Business Central
    01:45 How to make a simple API call with a json reply in Business Central
    03:20 To make a simple API call with a JSON reply in Business Central, we need to create a 'get ip' function and an HTTP client.
    04:54 Making a simple API call in Business Central
    06:27 The video discusses creating a JSON object and retrieving a specific field from it.
    07:48 Creating a JSON token called result and accessing its value as text.
    09:19 Retrieve JSON token from a specific field and convert it to a text value.
    10:47 Calling a simple API in Business Central

  • @MiklosHollender
    @MiklosHollender 20 днів тому

    Erik, what can one do if one is still on like NAV2016 but wants to build things in a future-oriented way, to make it easy to move to BC? My guess would be to use variables of the DotNet type HTTPClient etc.

  • @shinyakiritani9734
    @shinyakiritani9734 8 місяців тому

    Hi,
    In my 'Response', there is no 'body' in it, just 'header'. Therefor no value or 'ip' field in it (ResponseTxt is empty). And it set IP is default value (127.0.0.1).
    I am newbie, please help me when you have free time.
    Anyway, thanks Erik!

  • @jaserghasemi2543
    @jaserghasemi2543 3 роки тому +1

    Thanks for making this video, helped me a lot!

  • @ibrahiemrasoelbaks5124
    @ibrahiemrasoelbaks5124 4 роки тому

    Erik thanks again. Great explanation and thanks for sharing your experience and skill-set. Very interested to see how to parse more complex scenario and using the other Json datatypes like JsonArray. Wow keep up the very good work!

  • @akashram1385
    @akashram1385 2 роки тому +1

    How can we access 2nd element 5th item instead of 1st element like array inside array in the place of 'ip' if we do have one more nested json element in this code only

    • @Hougaard
      @Hougaard  2 роки тому

      jsonarray.get()

    • @akashram1385
      @akashram1385 2 роки тому

      @@Hougaard Is it exit(Jsontextfield(jsonarray.get(index)))?

    • @akashram1385
      @akashram1385 2 роки тому

      @@Hougaard please help me out sir I'm beginner just learning the things now

    • @akashram1385
      @akashram1385 2 роки тому

      @@Hougaard In this code can you write the exact code 2 lines so that I can understand where to write these Jsonarray.get(index)

  • @ant1d0te
    @ant1d0te 4 роки тому +2

    Thank you!
    Could you please share some tips and tricks about working with Media?

    • @Hougaard
      @Hougaard  4 роки тому

      Maybe, give me an example of what you're thinking about?

    • @ant1d0te
      @ant1d0te 4 роки тому

      ​@@Hougaard Let's say we have Item, it has Attachments (based on 1173 Document Attachment). Let's say I would like to have excel files attached to several items that are Assembly components and I would like to have combined excel file on sales line.

    • @ant1d0te
      @ant1d0te 4 роки тому

      @@Hougaard Document Attachment has field 8 Document Reference ID, type Media. I am struggling to obtain attached file. :\

  • @Emprosys
    @Emprosys 3 роки тому

    Hi Erik, how can I call a REST API with Basic Authentication in BC. i was trying to find the syntax in httpclient but I could find any.

    • @Hougaard
      @Hougaard  3 роки тому

      You need to add a authorixzation header to the httprequest structure...

  • @syscondev6409
    @syscondev6409 2 роки тому

    Hi Erik, Do you have any videos on using Business Central Admin Center API? I can use Business Central API but I can't make it work trying to use the Admin Center API.

    • @Hougaard
      @Hougaard  2 роки тому

      Not yet, but I'll put that on the list :)

  • @tejalpanchal6051
    @tejalpanchal6051 2 роки тому

    Hi Erik is there any specific format available if i want to pass data in httpcontent with content type "application/x-www-form-urlencoded" because when i add data in json or text i am getting response like value is not found so is it any format available which i need to follow?

    • @Hougaard
      @Hougaard  2 роки тому

      Then you need to add a content-type header to the httpcontent variable

    • @tejalpanchal6051
      @tejalpanchal6051 2 роки тому

      @@Hougaard Thanks for reply can you please share example ?

  • @joeycarlisle9844
    @joeycarlisle9844 2 роки тому

    The docs say the httpclient methods are asynchronous. How do I handle async in AL?

  • @hariskorac419
    @hariskorac419 2 роки тому

    Thank you for this video.
    Do you know how to create deep insert api for OData? Is that possible without dotnet, and complex types which used dotnet?
    I try to figure how, but without success. I want to get all item variants from item variants, item categories from item categories, for every item. But when I insert information from that pages, as a part on header Item page, as result I get only fields from 'header' page.

    • @Hougaard
      @Hougaard  2 роки тому

      Have you forgot ApplicationArea?

    • @hariskorac419
      @hariskorac419 2 роки тому

      @@Hougaard
      No. I don't.
      I input all results into Json Array, and write into text field. But only I got its values with double quotes in single line. I don't know how to remove quotes , or to set that JSON understand what is attribute and what is value, to have clean json. Thank you.

  • @sufletdemustang
    @sufletdemustang Рік тому

    Simple and efficient! Thanks!

  • @kenozakesy2372
    @kenozakesy2372 2 роки тому

    Thanks, but I get 127.0.0.1 as my IP address. How can I connect my docker to my local network?

    • @Hougaard
      @Hougaard  2 роки тому

      No, I'm pretty sure you have another IP address

    • @kristofdeprest9117
      @kristofdeprest9117 Рік тому

      @@Hougaard Same here, on BC Cloud

  • @ScrollwithSpyder
    @ScrollwithSpyder Рік тому

    hello sir ,
    can you guide me how can i get Quickbooks API in business central

    • @Hougaard
      @Hougaard  Рік тому

      Haven't played with that...

  • @soogood572
    @soogood572 3 роки тому

    You saved my life thank you so much¡¡¡

  • @yogeshsonawane997
    @yogeshsonawane997 3 роки тому

    Hi Erik ,
    Thanks for the knoledge ,can you please share how we pass body(In Json format) request in API call

    • @Hougaard
      @Hougaard  3 роки тому

      Set method to POST and supply a HttpContent into the HttpRequestMessage.Content field.

    • @shailamodi284
      @shailamodi284 2 роки тому

      @@Hougaard Can you please share an example of POST method with body as json.
      As i'm still struggling in it.
      Not getting where to pass request in the api call.

  • @anotherdev6057
    @anotherdev6057 4 роки тому

    Thank you for the video. Do we get the real public Ip if we run within docker ?

    • @Hougaard
      @Hougaard  4 роки тому

      Yes you do, because the web service tells you the IP as they see it.

    • @anotherdev6057
      @anotherdev6057 4 роки тому

      Thank you.

  • @shailamodi284
    @shailamodi284 2 роки тому

    Can you please share an example of POST method with body as json.
    As i'm still struggling in it.
    Not getting where to pass request in the api call.

    • @Hougaard
      @Hougaard  2 роки тому

      Build a HttpContent variable with the json (as text), add that to the httprequest.content and remember to set the Content-Type header to json/application

    • @shailamodi284
      @shailamodi284 2 роки тому

      @@Hougaard Where to pass HttpRequestMessage in api call??

    • @Hougaard
      @Hougaard  2 роки тому

      HttpClient.Send(httprequest,httpresponse)

    • @shailamodi284
      @shailamodi284 2 роки тому

      @@Hougaard Pls tell me how to add Content-Type as i'm getting error.

    • @Hougaard
      @Hougaard  2 роки тому

      Content.GetHeaders(cHeaders);
      cHeaders.Remove('Content-Type');
      cHeaders.Add('Content-Type', 'application/json;');
      Request.Content := Content;

  • @eniine3
    @eniine3 4 роки тому

    Wonderfull video Erik. i'm waiting for other videos , in particular for BC Saas (ex upload files etc..)

    • @Hougaard
      @Hougaard  4 роки тому

      What kind of files are you thinking about?

  • @pablohigueros2595
    @pablohigueros2595 2 роки тому

    Can you show how to post BC data to an external API?

    • @Hougaard
      @Hougaard  2 роки тому

      Check this: ua-cam.com/video/GaZoH-tQYuA/v-deo.html

  • @svenbeck1862
    @svenbeck1862 2 роки тому

    thanks for the great content. if you reference another video it would be great if you could directly add it to the description. you have so much content, so searching is difficult. i am referring to the following: ua-cam.com/video/fcUeYUpO2jw/v-deo.html

    • @Hougaard
      @Hougaard  2 роки тому

      I try to, but also relying on great people like you to help in the comments, thanks!