NetTalk Central

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Jane

Pages: [1] 2 3 ... 25
1
The Rest - Ask For Help / Re: Need embed point for calculations, please
« on: February 09, 2025, 08:09:13 PM »
As a starting point, I'd try this embed.
 

2
Web Server - Ask For Help / Re: Microservices?
« on: February 06, 2025, 12:28:50 PM »
What is the problem you're trying to solve?

3
Poul,

Don't know what you did with editing the shipping theme that didn't work, but the custom.css you're using won't do what you want.

What you're showing doesn't change the behavior of Bruce's css.  You need to include something for that selector that overrides what's in the original css.

Something like this, for example, should work in your custom.css:

Code: [Select]
@media (max-width: 1024px) { /*for small screens */
   .nt-browse-row-header{
      display:flex!important;
   }
}


4
Web Server - Ask For Help / Re: 2 way certificate authentication
« on: January 08, 2025, 03:10:58 PM »
Thanks for the update, Joep,

Glad you got it working.  You didn't attach a picture, but then it's a *hidden* window ;)

As you've found, the key is to think of the client part as a client and the webserver part as a webserver.

Good job!

5
It has nothing to do with recompiling.  When you ran the app with /IS the service information was created in the Registry.

If the wrong path is displaying on the Properties page in the services.msc app, easiest is to uninstall the service and reinstall it in the correct folder.

Or you could edit it in the Registry.




6
The Rest - Ask For Help / Re: Rest API - bad request reply
« on: December 29, 2024, 11:33:36 AM »
Johan,

As a first suggestion, try compiling with
Code: [Select]
NetShowSend=>1and then using debugview++

Another tool I've found useful is to run Fiddler and use it to monitor traffic in and out.  If you have an app (Postman, maybe?) that works and one that doesn't, that can be useful to compare what the two different apps are sending.

7
The Rest - Ask For Help / Re: Need help understanding NT commands
« on: December 27, 2024, 02:24:38 PM »

8
The Rest - Ask For Help / Re: Need help understanding NT commands
« on: December 26, 2024, 11:34:03 AM »
 "C'mon, Man!" TM
Your post asks about ThisPage, RemoveHeader, and ServerResponse but you wanted the reply to be about how to use a token.
 "C'mon, Man!" TM  ;)

In working with  APIs I've found the best strategy FOR ME has been
1. Make it work with Postman
2. Using the Postman stuff as a guide, make it work with the NetDemo app.
3. Having figured that out, code it into my app.

In my apps that need to call an API I typically have two procedures.
1. Fetches a token.  In my case, it first checks to see whether it has an existing token available that hasn't expired.
2. A generic "fetch stuff" API call. 

The "fetch stuff" procedure (sendGetPacket) is a generic window procedure having a prototype of
Code: [Select]
(STRING pURL, STRING pToken,StringTheory pST),LONG
The procedure that wants to fetch something creates the URL for the endpoint creates the required URL and passes the URL, the token, and a String Theory object to the sendGetPacket procedure.  When it's done, the StringTheory parameter contains what I've fetched from the API endpoint and I do what I do with it in the calling procedure.

The sentGetPacket has this code, much of which is snipped out of the NetDemo web client procedure.

Code: [Select]
PacketSend            ROUTINE
DATA

  CODE   

  ThisWebClient.SetAllHeadersDefault()

  ThisWebClient.HeaderOnly = 0
  ThisWebClient.Cookie = ''
  ThisWebClient.CustomHeader = 'Authorization: Bearer '&clip(pToken)
  ThisWebClient.Referer = ''   
  ThisWebClient.AsyncOpenTimeOut = 2200       ! 22 seconds
  ThisWebClient.InActiveTimeout = GLO:QueryTimeout            ! 6000        ! 20 seconds     
  ThisWebClient.SSLMethod = NET:SSLMethodTLS
  ThisWebClient.HTTPVersion = 'HTTP/1.1'
  ThisWebClient.ContentType = 'application/x-www-form-urlencoded'
  ThisWebClient.ConnectionKeepAlive = FALSE
  ThisWebClient.CanUseProxy = GLO:CanUseProxy
  ThisWebClient.ProxyServer = GLO:proxyServer
  ThisWebClient.ProxyPort = GLO:proxyPort 
  ThisWebClient.Fetch(clip(pURL))

The EVENT:OpenWindow event has this embed
Code: [Select]
      ! End of "Window Event Handling"
    OF EVENT:OpenWindow
      ! [Priority 5000]
      DO PacketSend

Other embeds:

Code: [Select]
ThisWebClient.ErrorTrap PROCEDURE(string errorStr,string functionName)

! Start of "NetTalk Method Data Section"
! [Priority 5000]

! End of "NetTalk Method Data Section"

  CODE
  ! Start of "NetTalk Method Executable Code Section"
  ! [Priority 2500]
        if self.Error <> 0
            ud.debug('error trap before parent '&clip(errorstr)&'  '&clip(functionName)&'  code='&ThisWebClient.Error)
            AddLog('net client error '&clip(errorstr),0,0)
            AddErrorLog('net client error '&clip(errorstr)&'  url='&left(pURL,80))
            post(event:closewindow)
        end ! if
  ! Parent Call
  PARENT.ErrorTrap(errorStr,functionName)
  ! [Priority 7500]
 

Code: [Select]
ThisWebClient.PageReceived PROCEDURE

! Start of "NetTalk Method Data Section"
! [Priority 5000]

! End of "NetTalk Method Data Section"

  CODE
  ! Start of "NetTalk Method Executable Code Section"
  ! [Priority 2500]
 
  ! Parent Call
  PARENT.PageReceived
  ! [Priority 7500]
    IF self.ServerResponse = 200
      self.RemoveHeader()
      LOC:RV = TRUE
      pST.SetValue(self.ThisPage.GetValue())
    ELSE
      LOC:RV = FALSE
    END !IF
    post(event:closewindow)
       

This is all OLD CODE I wrote 6 1/2 years ago, but it's been working fine since then.  YMMV.  Much of it, as mentioned, appropriated from the handy dandy NetDemo example program.  UD is the ClarionLive UltimateDebug object.

[edited] because I couldn't stand looking at the ugly pageReceived code I posted so I tweaked that app I pulled this from. [/edited]


HINT - that NetDemo example is handy  ;)


10
Web Server - Ask For Help / Re: 2 way certificate authentication
« on: December 19, 2024, 10:15:45 AM »
Quote
What I also wanted to ask is how I can do the get from a netwebservice method?

I have used client certificates to authenticate to servers, but not from NetTalk.  On this page there is some info on client-side certificates: https://www.capesoft.com/docs/NetTalk12/NetTalkWebClient.Htm   Bruce may have further advice.

I have, however, built a web server that is at the same time both an API server and an API client, which is what you're apparently doing.

The API client part is built like any of the API client examples that ship with NetTalk.  (Such as 77). 
Because an API request is asynchronous, you need a window running on a separate thread with a webclient object.  It authenticates to the server you're querying and fetches the data from that other server's API.  The window is obviously never visible to anyone; it's just used for the asynchronous process.  Once you've sorted the certificate authentication the rest will be quite straightforward.


11
Web Server - Ask For Help / Re: 2 way certificate authentication
« on: December 11, 2024, 01:31:46 PM »
Questions on terminology...

Are YOU accessing HIS API as a client?  And he wants you to use a certificate to authenticate yourself  (rather than something like name and password)? 

If that's what is meant by "2 way certificate authentication" then I think you need to figure out to use a client certificate (signed by him) to authenticate yourself to his API.  Remember that certificates have two basic (and partially independent) functions - encryption and authentication.  Maybe use Postman to do some tests for accessing his API.  And when you get that working, do the same with the NetDemo app.

12
Web Server - Ask For Help / Re: h2 Header styling - trying to apply color
« on: November 21, 2024, 10:12:38 AM »
Of course, if you want ALL h2 elements in your app to be red it's easiest to put a line into your custom.css file


Code: [Select]
h2{color:red;}
Remember that it doesn't take a period or hash mark before the h2 designation.

13
Argh!
Yes, sorry, Johan.  Appears that I zipped it before saving from IDE.
Attached is an updated zip. 
But looks as if you put the code in about the same place as I did.

Jane


14
C10?  Guess you like skinny templates ;)
Are you on NT 14, I hope?

Revised example C10/NT14 attached.

My code in the webhandler (line 14288 in p_web.SendFile procedure) looks for both procedure name and page name as specified on the procedure template.  Forced to lower-case a few lines above.

Code in this example is:

        case loc:filename
            of 'johan' orof 'johanpage'
            orof 'john' orof 'johnpage'
                p_web.trace('case triggered')
                p_web.SendError (404,'The page cannot be found', 'The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.')
                return
        end !case   


Seems to work OK.

Cheers,

Jane


15
Quote
Something I have not looked at,
is to add code to serve "page not found" HTML

Fairly easy to do with a few lines of code in the webhandler.
Maybe something like the attached? 

(Bruce page will serve, Johan and John pages will 404.)

Pages: [1] 2 3 ... 25