NetTalk Central

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Web Server - Ask For Help / Form field - Lookup using two keys
« Last post by Poul Jensen on December 28, 2024, 01:47:33 AM »
Hi,

This is a form where user - a mobile service technician - is entering items used on the job in question.
I need to validate a form field with the SKU number when it is accepted.
But the user can enter either SKU number or EAN number (entered from a barcode scanner) and I therefore need to validate this manually, ie. not using the normal wizarded lookup settings tab.

In the windows application I simply do this in the fields accepted embed, but how do I do this in NT?
The Routine  Validate --> Field does not fire at this point, but when the form is saved.

tiua
/Poul
22
The Rest - Ask For Help / Re: Need help understanding NT commands
« Last post by Jane on December 27, 2024, 02:24:38 PM »
23
The Rest - Ask For Help / Re: Need help understanding NT commands
« Last post by PeterPetropoulos on December 27, 2024, 09:32:17 AM »
WOO HOO!

IT WOIX!

No errors (reported ;-!  We got Data!

Jane,
Many thanks!

Yoiks and away!
24
The Rest - Ask For Help / Re: Need help understanding NT commands
« Last post by Jane 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  ;)

25
The Rest - Ask For Help / Re: Need help understanding NT commands
« Last post by PeterPetropoulos on December 26, 2024, 07:59:51 AM »
Jane,

Thank you.  I've read through all this several times.
I need an example that is more than ('something',whatever :-)

I know that there are multiple ways to get this right, but I am losing time getting it wrong.

Having received a token from my REST server after logging in, how do I use that token in formatting the next request?
The generated docs show me how to ask for a record, or a group of records, but I need to get that token in the right place, and that's not happening yet.  I know that because the server is giving me the equivalent of 'I know thee not.'

More specifically, DebugView is showing me that the variable file names are not getting set.  That means my message to the server failed.

27
The Rest - Ask For Help / Need help understanding NT commands
« Last post by PeterPetropoulos on December 22, 2024, 09:30:26 AM »
I have a desktop program communicating with an API server I built.
In the net.PageReceived procedure, I've been advised to use

self.RemoveHeader
self.ServerResponse
self.ThisPage

I don't understand what they do or how to use them.  I am looking for documentation that will tell me how to use these procedures, whether to include parameters or return values, for instance.   Having searched the NT documentation and the Developing pdf, I cannot find them.

Where can I find documentation on these procedures?  Is it a matter of 'read the code?'
28
Web Server - Ask For Help / Re: 2 way certificate authentication
« Last post by joep on December 21, 2024, 02:13:44 AM »
Hi Bruce and Jane
This is indeed how I have to go on.
With the automatic Window procedure and the call from the NetWebServiceMethod server code I can do the second call.
And with a new key and crt file in place this one is secure too. (I will make the crt and key file with openssl  from the pfx I got from the consumer)
Thanks both for your understanding and suggestions.
I wil let you know when or if this works.
Thanks Joep
29
Web Server - Ask For Help / Re: 2 way certificate authentication
« Last post by Bruce on December 20, 2024, 06:28:27 PM »
>> What I also wanted to ask is how I can do the get from a netwebservice method?

you make an automatic Window procedure, and call it from your NetWebServiceMethod server code at the appropriate time.
See the NetTalk WebServer Email example that follows the same pattern - albeit with a NetEmail object, whereas you will use a NetWebClient object.

The NetWebClient method can use a private key, if that's a thing the other server requires of you.

Cheers
Bruce
30
Web Server - Ask For Help / Re: Sending mail using Postmark API
« Last post by Bruce on December 20, 2024, 06:24:23 PM »
cid: is just a prefix to source names in the HTML which mean "find this in the attachment list".
so, for example;
<img src="c:\images\a.png"> becomes
<img src="cid:a.png">
and a.png is added as an attachment.

As you note the NetEmail class has methods to do this for you. But it's not hard for you to do it yourself.

Cheers
Bruce
Pages: 1 2 [3] 4 5 ... 10