Page 1 of 1

XPRIM_HTTPRequest vs CSV Data

Posted: Thu May 17, 2018 12:49 am
by MarcusLancaster
Hi all.

I've been playing with using the XPRIM_HTTPRequest to download a CSV from an Azure Blob, in a Container, into a server routine.

That works... and I can see that the HTTPRequest.Response does indeed contain the data... but it is just a stream of characters, with the odd linefeed.

What I really want to do is either;

a) Get the response data pushed immediately into a local file (from which I could then use TRANSFORM_FILE to push the data into a working list), or
b) Use another XPRIM utility to directly load the response data into a working list.

But I can't see any options which might give me that functionality... I guess I could receive the data as a string and chop it up and re-assemble as a working list... but that seems quite clunky... and I'm going to run into performance / field size issues, maybe...

So - the bottom line is - can I use the XPRIM_HTTPRequest to grab a CSV and load it straight into a working list (in a server routine) or dump it straight out into a local file.

I suppose I could use Integrator... but was trying to use some of the newer toys first... and just thought I'd check with the forum first...

Cheers for now.


Re: XPRIM_HTTPRequest vs CSV Data

Posted: Thu May 17, 2018 9:59 am
by tsupartono
The Response object has an AsFile method that would save the response to a file (you can then use TRANSFORM_FILE function to convert that to a list)

Have a look at the documentation below for all the available options: ... 0_0135.htm

See example below - this saves the response to a temporary file

Code: Select all

Define_Com Class(#PRIM_DC.UnicodeString) Name(#Path)
Define_Com Class(#XPRIM_HttpRequest) Name(#HttpRequest)

* Do your HTTP request
* Save the response to a temporary file (the path of the file is automatically generated)

#HttpRequest.Response.AsFile AutoDelete(True) Result(#Path)

* Use TRANSFORM_FILE (passing #Path.AsNativeString as the input file path)

Re: XPRIM_HTTPRequest vs CSV Data

Posted: Thu May 17, 2018 5:54 pm
by MarcusLancaster

Brilliant! Much appreciated... yep works a treat! I've now got my test CSV downloaded from Azure, into the server module, transformed and passed down to the client as a list.

Thanks for this.