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
2:40 "Now it's working like... Butterrrrrrr."
Never change, Erik.
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
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.
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!
Thanks for making this video, helped me a lot!
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!
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
jsonarray.get()
@@Hougaard Is it exit(Jsontextfield(jsonarray.get(index)))?
@@Hougaard please help me out sir I'm beginner just learning the things now
@@Hougaard In this code can you write the exact code 2 lines so that I can understand where to write these Jsonarray.get(index)
Thank you!
Could you please share some tips and tricks about working with Media?
Maybe, give me an example of what you're thinking about?
@@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.
@@Hougaard Document Attachment has field 8 Document Reference ID, type Media. I am struggling to obtain attached file. :\
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.
You need to add a authorixzation header to the httprequest structure...
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.
Not yet, but I'll put that on the list :)
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?
Then you need to add a content-type header to the httpcontent variable
@@Hougaard Thanks for reply can you please share example ?
The docs say the httpclient methods are asynchronous. How do I handle async in AL?
They're not
It might be that you are mixing it with the .NET documentation
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.
Have you forgot ApplicationArea?
@@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.
Simple and efficient! Thanks!
Thanks, but I get 127.0.0.1 as my IP address. How can I connect my docker to my local network?
No, I'm pretty sure you have another IP address
@@Hougaard Same here, on BC Cloud
hello sir ,
can you guide me how can i get Quickbooks API in business central
Haven't played with that...
You saved my life thank you so much¡¡¡
Hi Erik ,
Thanks for the knoledge ,can you please share how we pass body(In Json format) request in API call
Set method to POST and supply a HttpContent into the HttpRequestMessage.Content field.
@@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.
Thank you for the video. Do we get the real public Ip if we run within docker ?
Yes you do, because the web service tells you the IP as they see it.
Thank you.
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.
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
@@Hougaard Where to pass HttpRequestMessage in api call??
HttpClient.Send(httprequest,httpresponse)
@@Hougaard Pls tell me how to add Content-Type as i'm getting error.
Content.GetHeaders(cHeaders);
cHeaders.Remove('Content-Type');
cHeaders.Add('Content-Type', 'application/json;');
Request.Content := Content;
Wonderfull video Erik. i'm waiting for other videos , in particular for BC Saas (ex upload files etc..)
What kind of files are you thinking about?
Can you show how to post BC data to an external API?
Check this: ua-cam.com/video/GaZoH-tQYuA/v-deo.html
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
I try to, but also relying on great people like you to help in the comments, thanks!