You're url-open extension function only has the target attribute. If you're doing a get of your json file from ftp, the child of the url-open won't be there since you are not sending a payload, but instead a get request. You'll need to add the response="responsecode-binary" attribute to indicate that you are not expecting an XML response. See https://www.ibm.com/docs/en/datapower-gateway/10.0.1?topic=elements-dpurl-open to see what the XML results of using the attribute are. For a http(s) request this is documented as returning an XML document like the following. Other than the binary element in the result, I'm not sure what metadata is also returned for a ftp url-open, but you could dump the result to a temporary file using the dp:dump-nodes extension function if you're curious.
This will place the non-xml response in what is called a binaryNode, a DataPower only XML node type. You can then use the dp:binaryNodeToString extension function (https://www.ibm.com/docs/en/datapower-gateway/10.0.1?topic=functions-dpbinarynodetostring) on the result to translate that binary node to a string with your JSON ascii text. So something like
Original Message:
Sent: Wed February 15, 2023 01:09 AM
From: Vyasavardhan Ramagiri
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi @Steve Linn
I tried it but Iam unable to achieve what Iam looking for. Here is the snippet of codes which I used to read a Json file from ftp. Please go through it and let me know where Iam going wrong. And treat this as a priority. I need to complete this by today EOD.
Thanks in Advance Steve!!
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Tue February 14, 2023 10:01 AM
From: Steve Linn
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi Vyasavardhan,
See
https://www.ibm.com/docs/en/datapower-gateway/10.0.1?topic=elements-dpurl-open ,
specifically you'll need to provide the response attribute of the dp:url-open as binary node. Then you can use the dp:binaryNodeAsString extension to get the JSON in ascii.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Tue February 14, 2023 08:57 AM
From: Vyasavardhan Ramagiri
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
hi @Matthias Siebler
thanks for the rly and I have another doubt.
what if it is just a small JSON file with some kb's so I need to read it since gateway script won't support for ftp and SQL need to call with XSLT. so please help me in this with a snippet or something else.
Iam able to read xml file using XSLT but Json cannot be handled with XSLT, so I need to read it using gateway script in that XSLT .
Thanks in advance!
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Tue February 14, 2023 08:09 AM
From: Matthias Siebler
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi yes it is possible to read a ftp file using xslt url-open call.
Note that url-open cannot stream the data; it will be buffered in memory; so how large can the file be?
If it is very large; e.g. several gigs; then that can be a concern for memory management & also the parsing limits set on the xml manager.
------------------------------
Matthias Siebler
DataPower L3 Team Lead
Original Message:
Sent: Tue February 14, 2023 06:20 AM
From: Vyasavardhan Ramagiri
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi @Steve Linn
XSLT code is reading an xml file from ftp server what if i want to read the json or csv file from ftp using api connect v10 via dp:url-open
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Thu February 09, 2023 11:36 AM
From: Steve Linn
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi Vyasavardhan,
Since multipart/form-data can have multiple parts/files, how are you extracting each file(s)? GatewayScript would be the best approach to parse out each part based upon the boundary specified in the content type header, but sending that file to a ftp server or database would require an xslt that would be called from your GatewayScript using a transform.xslt asynchronous function call, passing your file data, perhaps wrapped in an xml tag, as input to your stylesheet. Note GatewayScript itself only supports via the urlopen module the http(s), (dp)mq, and graphql protocols, but the xslt dp:url-open extension function would also support the ftp or sql protocols. See https://www.ibm.com/docs/en/datapower-gateway/10.0.1?topic=open-url-sql. For your question about handling "data inside the file", your csv file is ascii but 4MB is a lot of data to process, what would that really be? A CSV of thousands of rows that would require thousands of SQL Inserts? That would seem to be a very latent process that would consume a lot of resources in the gateway while processing. Perhaps you can explain further what you're trying to accomplish with your Database.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Wed February 08, 2023 01:23 AM
From: Vyasavardhan Ramagiri
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi @Matthias Siebler
let my file is of 4mb and and it is CSV extension and the data inside is PIPE Separated. I want to test this first in my local if achieved then I'll implement in real-time.
Consider I am using a FileZilla ftp server for testing and an Oracle Database.
Now my question is,
Am I able to send the incoming multipart/form-data file to FTP server and at the same time I want to handle the data inside the file and I want to insert the data in specified fields of Oracle Database?
If we can do this by using IBM API Connect v10 Please let me know how can this be achieved. If possible send me the yaml or code snippets to do this.
Thanks in Advance @Matthias Siebler !
Regards
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Wed February 08, 2023 12:53 AM
From: Matthias Siebler
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi sorry can you give us more data? What type of database & ftp server?
How big is the data?
------------------------------
Matthias Siebler
MA
Original Message:
Sent: Sat February 04, 2023 05:22 AM
From: Vyasavardhan Ramagiri
Subject: Can we able to send a file from multipart/form-data to a ftp server and a database at a time using IBM APIconnect V10
Hi All,
I've a requirement like iam getting a bulk file in form-data from a client to my API Connect and I need to Transfer that file to a ftp server and a Database.
Do we able to do with gatewayscript coding? If yes please let me know how can we do that.
------------------------------
Vyasavardhan Ramagiri
------------------------------