cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-730359%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EDescarga%20de%20un%20archivo%20de%20la%20web%20con%20el%20encabezado%20%22disposici%C3%B3n%20de%20contenido%3A%20archivo%20adjunto%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-730359%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20would%20like%20to%20download%20a%20csv%20file%20from%20a%20webpage%2C%20however%20when%20I%20send%20the%20HTTP%20request%20the%20return%20is%20Empty().%20My%20code%20is%20as%20follows%3A%3CCODE%20class%3D%22%20language-jsl%22%3E%3C%2FCODE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E%3C%2FCODE%3E%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Erequest%20%3D%20New%20HTTP%20Request(%20URL(%20url)%2C%20Method(%20%22Get%22%20)%2C%20Headers(%20%7B%22Authorization%3A%20Bearer%20%22%20%7C%7C%20token%7D%20))%3B%0Adata%20%3D%20request%20%26lt%3B%26lt%3B%20send%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ERecibo%20el%20siguiente%20encabezado%20de%20respuesta%2C%20por%20lo%20que%20estoy%20seguro%20de%20que%20estoy%20accediendo%20al%20servidor%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EGetResponseHeaders%20%3D%20%5B%22content-disposition%22%20%3D%26gt%3B%20%22attachment%3B%20filename%3Dtext.csv%22%2C%20%22content-type%22%20%3D%26gt%3B%20%22text%2Fcsv%3B%20charset%3Dutf-8%22%2C%20%22date%22%20%3D%26gt%3B%2006Mar2024%3A17%3A08%3A05%2C%20%22server%22%20%3D%26gt%3B%20%22uvicorn%22%2C%20%22transfer-encoding%22%20%3D%26gt%3B%20%22chunked%22%5D%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ESin%20embargo%2C%20los%20datos%20est%C3%A1n%20vac%C3%ADos%20().%20Me%20gustar%C3%ADa%20descargar%20el%20archivo%20text.csv%2C%20pero%20no%20he%20podido%20encontrar%20una%20manera%20de%20hacerlo%20en%20JSL.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-730359%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAutomatizaci%C3%B3n%20y%20secuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAcceso%20a%20los%20datos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-733287%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Descargar%20un%20archivo%20desde%20la%20web%20con%20el%20encabezado%20%22disposici%C3%B3n%20de%20contenido%3A%20archivo%20adjunto%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-733287%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ELo%20m%C3%A1s%20probable%20es%20que%2C%20al%20menos%20parcialmente%2C%20dependa%20de%20su%20punto%20final.%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FDiscussions%2FHTTP-request-get-file-download-Operation-timed-out-after-60000%2Fm-p%2F224384%23U224384%22%20class%3D%22lia-mention-container-editor-message%20lia-img-icon-forum-thread%20lia-fa-icon%20lia-fa-forum%20lia-fa-thread%20lia-fa%22%20target%3D%22_blank%22%3EObtenci%C3%B3n%20de%20solicitud%20HTTP%20(descarga%20de%20archivos)%3A%20la%20operaci%C3%B3n%20expir%C3%B3%20despu%C3%A9s%20de%2060000%20milisegundos%3C%2FA%3E%20o%20tal%20vez%3C%2FP%3E%0A%3CP%3E%26lt%3B%26lt%3B%20La%20descarga%20funcionar%C3%ADa%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1710241573444.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1710241573444.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F62112i9C71A505624F8305%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22jthi_0-1710241573444.png%22%20alt%3D%22jthi_0-1710241573444.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Arequest%20%3D%20New%20HTTP%20Request(%0A%09URL(%0A%09%09%22https%3A%2F%2Fcommunity.jmp.com%2Fkvoqx44227%2Fattachments%2Fkvoqx44227%2Fsample-data%2F49%2F1%2FBlueBirds.jmp%22%0A%09)%2C%0A%09Method(%22Get%22)%0A)%3B%0Afile%20%3D%20request%20%26lt%3B%26lt%3B%20Download(%0A%09%22%24TEMP%2FBlueBirds.jmp%22%2C%20%22replace%22%2C%20%22show%20progress%22%0A)%3B%0AIf(!Is%20Empty(file)%2C%0A%09Open(file)%0A)%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%20%3C%2FP%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar

Downloading a file from web with header "content-disposition: attachment"

I would like to download a csv file from a webpage, however when I send the HTTP request the return is Empty(). My code is as follows:

request = New HTTP Request( URL( url), Method( "Get" ), Headers( {"Authorization: Bearer " || token} ));
data = request << send;

I receive the following response header, so I'm confident I am accessing the server: 

GetResponseHeaders = ["content-disposition" => "attachment; filename=text.csv", "content-type" => "text/csv; charset=utf-8", "date" => 06Mar2024:17:08:05, "server" => "uvicorn", "transfer-encoding" => "chunked"];

However data is Empty().  I would like to download the text.csv file, but have been unable to find a way to do so in JSL. 

 

 

1 REPLY 1
jthi
Super User

Re: Downloading a file from web with header "content-disposition: attachment"

Most likely, at least partially, depends on your endpoint. HTTP request get (file download): Operation timed out after 60000 milliseconds or maybe 

<< Download would work

jthi_0-1710241573444.png

 

 

Names Default To Here(1);

request = New HTTP Request(
	URL(
		"https://community.jmp.com/kvoqx44227/attachments/kvoqx44227/sample-data/49/1/BlueBirds.jmp"
	),
	Method("Get")
);
file = request << Download(
	"$TEMP/BlueBirds.jmp", "replace", "show progress"
);
If(!Is Empty(file),
	Open(file)
);

 

 

-Jarmo

Recommended Articles