Page 1 of 1

Get JSON Data with NTLM authentication

Posted: Sat Jan 05, 2019 4:40 pm
by sika05
Hello,

I want to put my data JSON into an array. With the integrated library this works well
on sites without login.

Code: Select all

set the itemDelimiter to slash
   put URL "https://open library. org/api/books?bibkeys=ISBN:0385472579,LCCN:62019420&format=json" into NewsContent
   put the result into theError
   if theError is empty then
      put JSONToArray(NewsContent) into tArray
How can I use the "URL" command with NTLM Autentication. I need to add header data, but I don't find a
possibility for this?

Code: Select all

var client = new RestClient("http://srzg023. xxx. local:7048/NAV130-CH-ORIG/api/beta/companies");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "NTLM TlRMTVNTUAADAAAAGAAYAGgAAAAYABgAgAAAAAAAAABIAAAAIAAgAEgAAAAAAAAAaAAAAAAAAACYAAAABYKIogUBKAoAAAAPcwBpAGUAZwBmAHIAaQBlAGQALgBrAGEAcgBsAGUAcgAnpk+rQ3+mqQAAAAAAAAAAAAAAAAAAAACrY7GaUtg0ZZzDkkKuc8YsrwNIGR5tvhc=");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
Is this possible with live code?

Thx Siggi

Re: Get JSON Data with NTLM authentication

Posted: Sat Jan 05, 2019 7:22 pm
by trevordevore
You can add headers to your URL requests using the `httpheaders` property.

Code: Select all

put "Content-Type: application/json" into tHeader
put CR & "Authorization: NTLM TlRMTVNTUAADAAAAGAAYAGgAAAAYABgAgAAAAAAAAABIAAAAIAAgAEgAAAAAAAAAaAAAAAAAAACYAAAABYKIogUBKAoAAAAPcwBpAGUAZwBmAHIAaQBlAGQALgBrAGEAcgBsAGUAcgAnpk+rQ3+mqQAAAAAAAAAAAAAAAAAAAACrY7GaUtg0ZZzDkkKuc8YsrwNIGR5tvhc=" after tHeader
set the httpheaders to tHeader
That being said, NTLM authentication requires a conversation with the server in order to generate the proper token. The internet library that ships with LiveCode Community doesn't support NTLM auth out of the box. If your copy of LiveCode includes tsNet then it may support NTLM auth automatically.

Re: Get JSON Data with NTLM authentication

Posted: Sun Jan 06, 2019 7:26 pm
by sika05
Hello Trevor,

thanks for the information. I first want to try if can create a application,
so I bought the community plus version.

Do you know that there is a possibility to add and use this tsnet component without buying the
expensive version?

I dont want so spend so much money only for testing, and when it not works with the programme
the money is wasted...

Thx
Siggi

Re: Get JSON Data with NTLM authentication

Posted: Sun Jan 06, 2019 9:08 pm
by trevordevore
I don’t know the answer to that. You could email LiveCode support and ask for details about NTLM authentication and tsNet to see if it will seamlessly work.