PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Envoi de fichier via API
Envoi de fichier via API
Iniciado por Mikael J. ( CW2S), 15,may. 2020 15:57 - 1 respuesta
Miembro registrado
3 mensajes
Publicado el 15,mayo 2020 - 15:57
Bonjour à tous dans le cadre d'un développement client,

je dois avancer sur ce point d'un composant :

roWebAPI - Overview

The roWebAPI is designed to simplify the process of importing files in to the Route Optimiser system and receiving the results.

After authentication, the first stage is the process of uploading the file to the system, which is done by a simple HTTP post. This can be achieved in most modern programming languages by applying the integration details shown below.

The second stage is receiving the processed results, which is achieved through an API request to the server.

Examples shown in this document are in their simplest form, HTML and XML, for a clear understanding of the expected process.

Currently the system can only handle one request per account until the result has been requested. Therefore the client could place multiple requests concurrently so long as they request the results prior to sending new data.

Posting data files to the API system.

Requirements

An account within Route Optimiser must be created and active for the process to work.

A token from the authentication process needs to exist and be passed in the URL call.

URL: /api/importData?token=<valid_token>

Each file must be sent as a POST file for the system to recognise it.

Files

An ROXML file and the import files.

Each file posted must have a unique name, just like you would with a HTML form field POST.

i.e.

<input type="file" name="file1" />

<input type="file" name="file2" />

Warnings

Uploading files of the same name of a previous upload may cause the previous file to be overwritten if the processing of data has not been completed.

Pour m'aider j'ai cette exemple de code en PHP
$ch = curl_init();
 
// set URL, should include full call to the API including the token
$url = $_POST['server'];
 
//$_FILES are the file data posted to the PHP page
 
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, 0);
 
$uploaddir = 'C:\\your\\path\\to\\temp\\directory\\';
 
$uploadfile1 = $uploaddir . basename($_FILES['file1']['name']);
move_uploaded_file($_FILES['file1']['tmp_name'], $uploadfile1);     
$data['file1'] = '@'.$uploadfile1.';filename='.basename($_FILES['file1']['name']);
 
$uploadfile2 = $uploaddir . basename($_FILES['file2']['name']);
move_uploaded_file($_FILES['file2']['tmp_name'], $uploadfile2);
$data['file2']='@'.$uploadfile2.';filename='.basename($_FILES['file2']['name']);
 
curl_setopt($ch, CURLOPT_HTTPHEADER,array("Expect:"));
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
 
$info = curl_getinfo($ch);
 
 
curl_close($ch);


Mais je n'arrive pas a le transcrire en Windev
et j 'en suis la ...
MyData est un restRequête
MyData..Méthode=httpPost
MyData..IgnoreErreur = httpIgnoreCertificatExpiré + httpIgnoreNomCertificatInvalide + httpIgnoreCertificatInvalide
MyData.URL=m_sAPI+"/api/maps/getMaps?token="+m_sToken


cMaReponse est un restRéponse = RESTEnvoie(MyData)
SI ErreurDétectée ALORS
Erreur(ErreurInfo(errComplet))
SINON

FIN


avez vous une idée ? une piste ? une réponse pour passer mes fichiers ?

merci par avance
Miembro registrado
3 mensajes
Publicado el 15,mayo 2020 - 16:00
il faut lire
MyData.URL=m_sAPI+"/api/importData?token="+m_sToken

je n 'arrive pas a éditer mon message