PxPlus User Forum

Twitter Twitter Twitter

Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Nomads / Re: Library Query
« Last post by Jane Raymond on May 27, 2024, 08:18:40 AM »
There are two possibilities:
  • In the Data Dictionary, use the expression GLWK+FID(0)+TCB(13) as your physical file name. Then, whenever a new  file is created, be sure to embed the dictionary. When the query runs, it will evaluate the file name and open it.
  • In the query definition, use the expression as the File/Table. If the dictionary is embedded in the file the expression evaluates to, it will use it.
12
Nomads / Library Query
« Last post by Mike Hatfield on May 27, 2024, 05:12:28 AM »
I want to create a Stanard Library Query where you pass it the file name to open for the query.
For example:
I want to create a query that will display a workfile that contains a set of transactions from the general ledger.
The workfile has a generated unique file name: EG GLWK+fid(0)+TCB(13)
I can create a File Dictionary table for a generic GLWK workfile.
My problem is how to tell the Query what file to read and how will it know to use the generic dictionary definition?

Thanks
13
Web Services / Re: Posting a File to a Web Service
« Last post by HendersonS on May 25, 2024, 03:15:43 PM »
Hi,
Jeff and Stéphane, thank you for your help, I was finally able to find the solution with the help you gave me.

the line looked like this:
Content-Disposition: form-data; name="xml"; filename="xmlsing.xml"
14
Web Services / Re: Posting a File to a Web Service
« Last post by Stéphane Devouard on May 25, 2024, 01:07:34 PM »
Henderson,

Jeff’s suggestion is only an example, you need to check the documentation of the API you’re trying to interact with and see what is the name of the html form field that this API expects. If filename does not work, maybe it is file_name or xml_file.
Also make sure that the data in the XML file is escaped using either cvs(…, "utf8:xml") if the data may contain utf8 encoded characters, or cvs(…, "ascii:xml") in case the data contains reserved XML chars such as < >


Jeff,

You can spare a call by using the cvs() function
base64_credentials$ = cvs(raw_credentials$, "ascii:base64")
15
Web Services / Re: Posting a File to a Web Service
« Last post by HendersonS on May 24, 2024, 05:01:04 PM »
jeff,

I tested both ways that you showed me and I still get the same "invalid file" response, I will continue trying...
16
Web Services / Re: Posting a File to a Web Service
« Last post by Jeffrey Ferreira on May 24, 2024, 04:41:42 PM »
i think the problem is this line
Content-Disposition: form-data; name="xmlsing"; filename="xmlsing.xml"

Mine looks like this
Content-Disposition: form-data; name="filename"; filename="s:\jeff\Cleary_Quote.xml"

i feel like your line should like something like this:

Content-Disposition: form-data; name="filename"; filename="xmlsing.xml"
in other words
the value that name =  points to should be the key in the next key value pair
i have to head out but i'll try to check back in again later on this.
                                                           
17
Web Services / Re: Posting a File to a Web Service
« Last post by HendersonS on May 24, 2024, 04:23:52 PM »
jeff, this is what it returns:

1>print mid(body$,1,300)
------PxPlusFormDataBoundary_zNYKbtQdhRIYGlYIDBoKNPAdi7un9gGR
Content-Disposition: form-data; name="xmlsing"; filename="xmlsing.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="utf-8"?>
<SemillaModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="h
ttp://www.w3.
1>
18
Web Services / Re: Posting a File to a Web Service
« Last post by Jeffrey Ferreira on May 24, 2024, 04:10:23 PM »
Henderson, for me the problem was that keyword file/filename that i had to pass in.
i feel like you might have to pass in the word "xml"
i could be wrong.
do me a favor - you know where i have
1080 let BODY$=UPLOAD'BODY$() ! Calling Stephane's code
after you execute this method
print the mid(body$,1,300) and then send the contents to this thread...
19
Web Services / Re: Posting a File to a Web Service
« Last post by HendersonS on May 24, 2024, 03:58:55 PM »
Jeff thanks for your help,

I have something very similar to what you showed, I also added Stephane's program to calculate the boundaries but when I send it with pxplus the API returns an "invalid file" error, I tried it with CURL and the api receives the file correctly, does it work? How could I replicate it? in Pxplus?

Example with CURL:
Code: [Select]
curl -X 'POST' \
  'https://url/api' \
  -H 'accept: application/json' \
  -H 'Content-Type: multipart/form-data' \
  -F 'xml=@xmldata.xml;type=text/xml'
20
Web Services / Re: Posting a File to a Web Service
« Last post by Jeffrey Ferreira on May 24, 2024, 02:55:03 PM »
Hi Henderson,

here was is my best try to scale down with no extra stuff
you need Stephane's program http.upload.pvc for this to work. The other stuff is standard pxplus.
if you can't get it working let me know.

0010 begin
0020 precision 4
0030 let XML_FILE$="s:\jeff\Cleary_Quote.xml" ! Your File would be different
0040 let RAW_CREDENTIALS$="login:password" ! Using Basic Credentials then separate your login and password with a colon before calling base64 program
0050 call "*web/base64;ENCODE_STR",RAW_CREDENTIALS$,BASE64_CREDENTIALS$
0060 let EXTRA_HEADERS$="Authorization: Basic "+BASE64_CREDENTIALS$
0070 let URI$="https://staging.saberis.com:9000/api/v1/documents/modules/21/upload"
0080 gosub HELPER
0090 call "*plus/web/request",URI$,BODY$,RESPONSE$,RESPONSE_HEADER$,CONTENT_TYPE$,"",EXTRA_HEADERS$
0100 print RESPONSE_HEADER$
0110 print RESPONSE$
0120 msgbox "Done"
0130 end
1000 ! ^1000
1010 HELPER:
1020 let FIELD_NAME$="filename" ! This part was custom for my api / yours will probably be different
1040 call "*tools/readfile",(XML_FILE$),FILE_CONTENTS$
1050 let FILE_MIME_TYPE$="multipart/form-data"
1060 let UPLOAD=new("http.upload",FIELD_NAME$,XML_FILE$,FILE_CONTENTS$,FILE_MIME_TYPE$) ! This is Stephane's program http.upload.pvc that handles the boundaries (this is part i was messing up (the boundaries))
1070 let CONTENT_TYPE$=UPLOAD'CONTENT_TYPE$
1080 let BODY$=UPLOAD'BODY$()
1090 return
Pages: 1 [2] 3 4 ... 10