PxPlus User Forum

Twitter Twitter Twitter

Recent Posts

Pages: [1] 2 3 ... 10
1
Web Services / Re: Posting a File to a Web Service
« Last post by Stéphane Devouard on Today at 03:47:31 AM »
Jeff

Attached is the PVX helper class I use to upload files to APIs

Use it like this :

Code: [Select]
field_name$="Name of the form field the webservice is waiting for"
file_name$="Name of the file to upload : this will be the value of the form field above"
file_content$="File content"
file_mime_type$="MIME type of the file to upload, application/octet-stream by default"
upload=new("http.upload",field_name$,file_name$,file_content$,file_mime_type$)
! // use upload'content_type$ as mime_type in the *plus/web/request
! // use upload'body$() as body in the *plus/web/request

The file_content$ variable should be loaded with a binary read of the file

Code: [Select]
open (hfn,isz=-1) file_name$
file_content$ = rcd(lfo,siz=10000000)

Hope this helps
2
Web Services / Posting a File to a Web Service
« Last post by Jeffrey Ferreira on May 17, 2024, 09:47:02 PM »
Hi List,
in the past i could never get *plus/web/request work with uploading a file.
i can get it to work in postman, curl and powershell....but i cannot get syntax right in pxplus
i'm referring to line 100 .
does anyone know what i'm doing wrong or has used *plus/web/request to post/upload file
i dont want to use a 3rd party utility if i can help it

0040 let RAW_CREDENTIALS$="username:password"
0050 call "*web/base64;ENCODE_STR",RAW_CREDENTIALS$,BASE64_CREDENTIALS$
0060 let EXTRA_HEADERS$="Authorization: Basic "+BASE64_CREDENTIALS$
0070 let MIME_TYPE$="multipart/form-data"
0080 let URI$="https://staging.saberis.com:9000/api/v1/documents/modules/21/upload"
0100 let BODY$="filename=Cleary_Quote.xml"
0110 call "*plus/web/request",URI$,BODY$,RESPONSE$,RESPONSE_HEADER$,MIME_TYPE$,"",EXTRA_HEADERS$


thanks

jeff
3
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by pwhirley on May 17, 2024, 04:27:31 PM »
It also never occurred to me to [execute call "myroutine",mynewvariable$].   That is a very easy way to get individual variables back on to the web page dynamically. 
Lots of options.
- Phil
4
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by pwhirley on May 17, 2024, 02:50:40 PM »
This is helpful, Mike!  It did not occur to me to execute "winprt_setup" rather than executing a separate subroutine which then executes "winprt_setup".

I believe I'll implement this.

Phil
5
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by Mike King on May 17, 2024, 12:26:16 PM »
Phil

Perhaps this will help.  The following page shows a list of all printers configured on your Windows server (Windows only).  You can select one and press the button which will force a crash so you can see the values..

Code: [Select]
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>[ttl]Mike Printer Select[/ttl]</p>
<p>[form]
[execute winprt_setup read printer$]
[execute winprt_setup list printerlist$][hide printerlist$]
[list printer$ size=50/10][data text=(printerlist$)][/list]<hr>
[button text="Force Dump" event=crash@crash]
[/form]</p>
</body>
</html>

I used the [execute] to load the current/default printer and the full printer list.

BTW: The [hide] for the printerlist$ is not required but was included so you could see the values in the dump.
6
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by pwhirley on May 17, 2024, 11:10:24 AM »
Thanks Susan!
I ended up doing something similar to get around my problem.  I created a "printers.dat" table and a query.  I execute a routine to update the printers.dat and inserted a query lookup for the Printers field on my form. 
One thing I didn't understand in your example:  In the place where I would put the delimited list of drop-down options, you just execute your little program the *memory* file.  How does Webster+ know that the contents of the memory file are to be used for the options?  Does it just know that any *memory* file contains the options or is there some other secret. 

Thanks also, Mike!
The program isn't a report but a setup definition for an automatic printing routine which will run in background.  Part of the set up is to define which label printer is to be used, so I need to present a list of the valid printers, which might well change from one day to the next.  I do save the user's choice in the profile definition file, but when the user is creating the definition, she needs to see all the available printers.  I thought I could just put the printer list in a variable built in an executed routine and pass that variable back to the Webster+ web page.  That was not working.  I'll take a look at the reports.html and *report files to see if I can see what I was doing wrong.

Thanks for the help, both of you!

Phil
7
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by Mike King on May 16, 2024, 03:33:59 PM »
Phil

There are any number of ways to add a printer list to a Webster+ panel.

If you have the list in a variable you can simply do something like:

[list printer$][data text=(printerlist$)][/list][/b]

You can see this in the *webster/pages/reports.html file where the system loads variable fieldNames$ which was added to the form using a [hide] short code.  This variable was loaded in the [form program=*report] which runs the INIT event in *webster/report.

Personally though I wouldn't put the printer list in the form.  No need to have the system load it on every request.  On windows you can have a fairly significant delay to get the list of printers if some of them are offline or misconfigured.

Instead I would create a drop down query for a printer$ input field and set the field as 'required'.  Whenever printer$ input is changed I would have an event that updates the user data with the last requested printer using the %webster'SetUserData() method so that all subsequent requests will have %usr.Printer$ with the last selected printer.  You can then use an [exec printer$=%usr.printer$] in your logic to initialize the value.

There are other methods such as using cookies, but personally I would suggest using the user data as that would provides consistency for the user regardless as to the browser.

8
Webster Plus / Re: Retrieving calculated string from program to web page
« Last post by Susan Cryderman on May 16, 2024, 11:03:45 AM »
Phil,

The difficulty here is that (I'm assuming) the list or printers needed is variable.  Because of this, the data needed for the drop box needs to be written to a memory file.

I tried the following and it seems to work (although I have not coded a Printer_Validate method).

1) Edited the _fm_panel_iol$ hidden variable in the html file to include printer$
2) Included the following code for the printer drop box:

 [row "*\[show usefile field=printer$\]:"][list printer$ size=20 event=Printer_Validate program=c:\webster\prog\tools][/list][/row]<br>

3) Coded the c:\webster\prog/tools program to load a memory file as follows:

 ! tools - load printer list
 !
  ENTER fileno
 !
  OPEN (HFN)"*memory*"
  fileno=LFO
 !
  printer_list$="Printer A/Printer B/Printer C/"
  FOR val$ FROM printer_list$
  WRITE (fileno,KEY=val$)
  NEXT
 !
  EXIT 

You would need to edit your Printer_List method accordingly.

Hope this helps!
9
Programming / Re: close programme
« Last post by EVa on May 16, 2024, 04:27:57 AM »
Without knowing what's in the PFILEBOX program, it's impossible to tell why this isn't working all of the time.  Also, your PxPlus version looks pretty old (I'm guessing v11 or older) - you could check if the problem still happens when using a current version of PxPlus.
10
Programming / Re: close programme
« Last post by Danilo David on May 15, 2024, 11:22:51 PM »
Hello

im using this line codes to upload a file:
32420 CALL %WINDX$+%DF1_SDRIVE$+"D"+"F"+"1"+"\"+"P"+"R"+"O"+"G"+"_"+"D"+"F"+"1"+"\"+"P"+"F"+"I"+"L"+"E"+"B"+"O"+"X",INPUT_PAD$,START_PAD$,MSG("Excel facescanner")


Thank you

regards,
Danilo



Pages: [1] 2 3 ... 10