@@Hougaard thanks for replying, but i don't have a JsonArray, i only have an like: "BrandNames": [ "Gucci","Prada","Fendi"] and i dont know how to store this in a JsonToken . My only workaround right now is passing it as a string and when i get the and reading the responsearray as a string and splitting it into a List ( which could create inconsistencies )
Keep up the good work Erik Little workaroud for pretty json local procedure PrettyJson(var JsonText: Text) var JSONManagement: Codeunit "JSON Management"; begin if JSONManagement.InitializeFromString(JsonText) then begin JsonText := JSONManagement.WriteObjectToString(); end; end;
Kan du lave en video om hvordan man laver en page i bc hvor man kan sende en ticket til zendesk. Jeg har hul igennem Zendesk api'et via postman, og jeg har en side klar lavet i AL, men jeg kan ikke lige gennemskue hvordan jeg poster til api'et i AL
Nice one Erik, just wonder have you ever met json with special characters. Like when exporting Item Card in Description you have special charcaters like " or tab or ' or * I've read we can use like \" or so but that means have to search all char in the description.
Great as always, Erik! A question. Is it all of them really called "Keys" and not "JSON Tokens"? I know for instance when you make an API to Sales Invoice, for example, BC will return a token called "Key" with a JSON Value. Much oblige
Thanks for the valuable content Erik! Perhaps you could get into making such complex structures available thru an API? We as BC Developers are constantly confronted with interfaces from and to external systems. But, MS has only the API Page for us to publish a REST/JSON API. The problem there is, you can only go 2 levels deep with a subpage. Yes there’s a OdataEDMType but 1. you cannot place an array (edm collection type) into another OdataEDMType and 2. it is deprecated since version 6, leaving us with an API Page and Subpage, max 2 levels deep. Since 3 versions no replacement for it! This is a joke. I wish they would allow a JSONObject Parameter in a codeunit, that way you could publish that codeunit as a web service and the parameter passes the json object, respectively XMLDocument. What’s your point of view? Perhaps i am missing something? Thanks Erik!
@@Hougaard Yes there’s already an object type XMLDocument (.net equivalent) that fits as replacement for XMLPort. But unfortunately you cannot publish it as a web service. We don’t even need SOAP anymore, it’s dead anyway. All we need is being able to publish a web service with either a XMLDocument or JSONObject parameter or perhaps give us access to the request object overall. Let us do the handling in code. BC Developers aren’t NAV Bookkeepers anymore :D. Perhaps there’s a reason why it is not possible but I cannot think of a reasonable explanation. It’s possible in almost every other language. Where’s the right place to suggest ideas?
I'm typically just doing function(input : Text) : Text and then do json parsing on input and json formatting on the return value. The only "issue" with this approach is that content-type is not set to application/json - but I just ignore that.
@@Hougaard yes i thought of that too but unfortunately there’s another issue: due to the text parameter the input json itself has to be encapsulated in a string, like „{ „key“: „value“}“ instead { „key“: „value“}. This is not valid according to REST / JSON specification. I have to explain that to the counterpart developer, complicating things for both sides…
Great Erik A question. Could you please make a tutorial about differences between adding header to an http client with DefaultRequestHeaders and with HttpContent.GetHeaders(HttpHeaders) and HttpHeaders.Add. Thank you ever so much
Very helpful, Sir! I watched all json videos, and more videos regarding other topics. Your content is making a big difference. Thank you!
How do you store an array of values for one fiield ? e.g. "Field1" : "["Value1","Value2","Value3"]
yourjsonobject.Add('FIeld1",);
@@Hougaard thanks for replying, but i don't have a JsonArray, i only have an like:
"BrandNames": [ "Gucci","Prada","Fendi"]
and i dont know how to store this in a JsonToken . My only workaround right now is passing it as a string and when i get the and reading the responsearray as a string and splitting it into a List ( which could create inconsistencies )
So that json as Text, so you gotta parse it first (with .ReadAs())
Keep up the good work Erik
Little workaroud for pretty json
local procedure PrettyJson(var JsonText: Text)
var
JSONManagement: Codeunit "JSON Management";
begin
if JSONManagement.InitializeFromString(JsonText) then begin
JsonText := JSONManagement.WriteObjectToString();
end;
end;
Kan du lave en video om hvordan man laver en page i bc hvor man kan sende en ticket til zendesk. Jeg har hul igennem Zendesk api'et via postman, og jeg har en side klar lavet i AL, men jeg kan ikke lige gennemskue hvordan jeg poster til api'et i AL
Der er allerede mange videoer om web service kald.. prøv at blive inspireret af nogle af dem?
Nice one Erik, just wonder have you ever met json with special characters. Like when exporting Item Card in Description you have special charcaters like " or tab or ' or *
I've read we can use like \" or so but that means have to search all char in the description.
Great as always, Erik!
A question.
Is it all of them really called "Keys" and not "JSON Tokens"?
I know for instance when you make an API to Sales Invoice, for example, BC will return a token called "Key" with a JSON Value.
Much oblige
A token is either a jsonobject, a jsonarray or a jsonvalue. A key is the indexing inside an jsonobject.
Thanks for the valuable content Erik! Perhaps you could get into making such complex structures available thru an API?
We as BC Developers are constantly confronted with interfaces from and to external systems. But, MS has only the API Page for us to publish a REST/JSON API. The problem there is, you can only go 2 levels deep with a subpage. Yes there’s a OdataEDMType but 1. you cannot place an array (edm collection type) into another OdataEDMType and 2. it is deprecated since version 6, leaving us with an API Page and Subpage, max 2 levels deep. Since 3 versions no replacement for it! This is a joke. I wish they would allow a JSONObject Parameter in a codeunit, that way you could publish that codeunit as a web service and the parameter passes the json object, respectively XMLDocument. What’s your point of view? Perhaps i am missing something? Thanks Erik!
What we're missing is a modern replacement for xmlport as a parameter.
@@Hougaard Yes there’s already an object type XMLDocument (.net equivalent) that fits as replacement for XMLPort. But unfortunately you cannot publish it as a web service. We don’t even need SOAP anymore, it’s dead anyway. All we need is being able to publish a web service with either a XMLDocument or JSONObject parameter or perhaps give us access to the request object overall. Let us do the handling in code. BC Developers aren’t NAV Bookkeepers anymore :D. Perhaps there’s a reason why it is not possible but I cannot think of a reasonable explanation. It’s possible in almost every other language. Where’s the right place to suggest ideas?
I'm typically just doing function(input : Text) : Text and then do json parsing on input and json formatting on the return value. The only "issue" with this approach is that content-type is not set to application/json - but I just ignore that.
@@Hougaard yes i thought of that too but unfortunately there’s another issue: due to the text parameter the input json itself has to be encapsulated in a string, like „{ „key“: „value“}“ instead { „key“: „value“}. This is not valid according to REST / JSON specification. I have to explain that to the counterpart developer, complicating things for both sides…
VSCode does know how to format json. Paste it into a .json file and do ‘format document’. No need for external dev toys
But I like DevToys :)
Great Erik
A question.
Could you please make a tutorial about differences between adding header to an http client with DefaultRequestHeaders and with HttpContent.GetHeaders(HttpHeaders) and HttpHeaders.Add.
Thank you ever so much
I'll put that on the list :)