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 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"
2
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")
3
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...
4
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.
                                                           
5
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>
6
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...
7
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'
8
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
9
Web Services / Re: Posting a File to a Web Service
« Last post by HendersonS on May 24, 2024, 02:36:43 PM »
Hi Jeff, I'm stuck in the same place trying to send a file via API, could you post the final solution? Maybe it can help me too!
10
General Announcements / Announcing PxPlus 2024
« Last post by PxPlus on May 24, 2024, 09:20:06 AM »
We are pleased to announce that PxPlus 2024 (v21) is available for download.

PxPlus 2024 includes new features to keep your applications safe, secure and modern

  • The Harvard Business Review reported a 20% increase in cyber security data breaches from 2022 to 2023. To protect your application and your customers' data, PxPlus 2024 is updated with the latest Security modules.

  • In speaking with the developer community, we learned that many developers are using Visual Studio Code in other areas of their development teams. PxPlus 2024 includes a new extension to Visual Studio Code, an industry-leading code editor that is the preferred choice for many developers.

  • In today’s competitive environment, the look and feel of an application is equally important as the functionality. PxPlus 2024 includes modern PxPlus toolkit interfaces showcasing Dark and Light modes, and new tools to update the look of your Nomads and non-Nomads based applications.

  • Webster+, launched in 2021, provides developers with the optimal toolset to convert your application to browser based. PxPlus 2024 continues to enhance Webster+ with the ability to create and maintain screen library objects using a Web browser with Webster+ Inspector.

  • We made it even easier for you to design your application screens for NOMADS and Webster+ with the new File Maintenance Generator Enhanced Layout.

For a complete overview of new features in this release, see the What’s New section.

Watch our short video introducing PxPlus 2024



Additional Resources

To download the software for PxPlus 2024, go to our Download Center.

To download the software for v8.00 PxPlus SQL ODBC Driver and PxPlus SQL Server , go to our Download Center.

For additional technical information, see our Documentation website.

The PVX Plus Team
Pages: [1] 2 3 ... 10