Error from tsNetGetSync

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Error from tsNetGetSync

Post by bmcgonag » Wed Mar 25, 2020 2:57 pm

I'm trying to call an API with tsNetGetSync based on a LiveCode Lesson I'm looking through. I have to send authorization as a header with a bearer token.

I read the token, and use that as a tHeader variable in my request, but when I run the code I get an error as follows:

Code: Select all

card "Home": execution error at line 8 (Function: error in function handler) near "tsNetGetSync", char 11
The code I'm running is as follows

Code: Select all

on preOpenCard
   put field APIToken on card "Settings" into apiToken
   if (apiToken = "") or (apiToken is empty) then
      -- just end here and wait.
   else
      put "https://my.zerotier.com/api/network" into apiUrl
      put "Authorization: bearer " && apiToken into apiHeader
      put tsNetGetSync(apiUrl, apiHeader, tRecvHeaders, tResult, tBytes) into tData
      
      if tResult is not 200 then 
         answer "Could not retrieve data" 
      else
         put tData into field apiReturndata
      end if
      
   end if
end preOpenCard
The error doesn't provide much in the way of what's wrong, and I'm afraid I don't have any idea since I'm following the lesson code for the API request as it is on screen.

Any help is greatly appreciated.

==========================================================

As a small update - I tried this lesson literally with no changes http://lessons.livecode.com/m/4071/l/84 ... a-web-site

And I get the following error:

Code: Select all

execution error at line 3 (Function: error in function handler) near "tsNetGetSync", char 8
Is there a way to verify if tsNetGetSync is included in the version I'm running of LiveCode? It's community edition 9.5.1

==========================================================

Update 2:

I tried some code to test if the connection was up and detected based on a thread lower down in this forum just using

Code: Select all

url("http://www.duckduckgo.com")
And it worked. So I am able to use URLs from LiveCode on this mac running catalina. But for some reason it's something about the tsNetGEt and / or tsNetGetSync functions that it seems to not like. Still digging, just not getting very far.

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Error from tsNetGetSync

Post by bmcgonag » Wed Mar 25, 2020 8:52 pm

Maybe I found my answer. The documentation in lessons doesn't specify which versions anything works on, so you just get to try it, fail with some obscure error, and not know why. I'm only guessing by a blog post from when tsNet was added, but it appears it's not available in community.

Thus it won't work. I don't mind at all making my code open source, but I can't use a falsely crippled system to build in. Back to VueJS and NeutralinoJS. Shame...and I get everyone needs to make money, but charge for support, or for Live or Online video lessons. Don't cripple what you've made. Just my opinion. LiveCode has some real promise. Maybe I'm wrong and there's just something weird with what I'm doing. Happy to find that out too.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Error from tsNetGetSync

Post by Klaus » Wed Mar 25, 2020 9:01 pm

Yes, tsNet only comes with "paid" versions of Livecode: INDY and BUSINESS.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Error from tsNetGetSync

Post by FourthWorld » Wed Mar 25, 2020 9:37 pm

bmcgonag wrote:
Wed Mar 25, 2020 8:52 pm
Maybe I found my answer. The documentation in lessons doesn't specify which versions anything works on, so you just get to try it, fail with some obscure error, and not know why. I'm only guessing by a blog post from when tsNet was added, but it appears it's not available in community.

Thus it won't work. I don't mind at all making my code open source, but I can't use a falsely crippled system to build in. Back to VueJS and NeutralinoJS. Shame...and I get everyone needs to make money, but charge for support, or for Live or Online video lessons. Don't cripple what you've made. Just my opinion. LiveCode has some real promise. Maybe I'm wrong and there's just something weird with what I'm doing. Happy to find that out too.
tsNet includes a few nice conveniences for HTTP, but is not necessary. Its main strength lies with other protocols.

All LiveCode editions support sockets, and LiveCode Community Edition includes libURL which provides good support for HTTP, HTTPS, and FTP.

Drop the tsNet syntax, look at POST and GET in the Dictionary (which are implemented in the LC engine in all editions), and let us know if you run into any snags.

For others down the road who may be similarly misled by incomplete tutorials discussing the edition-specific tsNet, I've submitted an enhancement request to clean up the Lessons on tsNet and expand the discussion to note libURL, which is not only available for all editions but has much cleaner, engine-integrated syntax:
https://quality.livecode.com/show_bug.cgi?id=22644
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Error from tsNetGetSync

Post by bogs » Wed Mar 25, 2020 9:57 pm

Nice ! :mrgreen:
Image

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Error from tsNetGetSync

Post by bmcgonag » Wed Mar 25, 2020 10:33 pm

FourthWorld wrote:
Wed Mar 25, 2020 9:37 pm
...Drop the tsNet syntax, look at POST and GET in the Dictionary (which are implemented in the LC engine in all editions), and let us know if you run into any snags.

For others down the road who may be similarly misled by incomplete tutorials discussing the edition-specific tsNet, I've submitted an enhancement request to clean up the Lessons on tsNet and expand the discussion to note libURL, which is not only available for all editions but has much cleaner, engine-integrated syntax:
https://quality.livecode.com/show_bug.cgi?id=22644
First, thanks for the response. I appreciate the point in the right direction. I'll give libUrl a shot with GET and httpHeaders (it looks like).

Also, thanks for updating the documentation. Definitely helpful to know if certain functions will work with a given version.

Post Reply

Return to “Internet”