Créer dossier API Rest
-
Bonjour,
Dans le cadre d'une application de gestion de convention j'envoie vers GoFast grâce à l'API Rest les fichiers de convention.
Mais j'aimerais que ces fichiers soit rangés dans des dossiers correspondant à l'année de la convention. Afin de ne pas créer plusieurs dossiers à l'avance et de pouvoir le faire automatiquement est-il possible de créer des dossiers via l'API Rest ?
Cordialement,
Comte Clément
-
Des Dossiers ou des Espaces ?
Si je suppose que vous utilisez Python :
Pour les dossiers , un acces webdav avec le package Webdav3 peut fonctionner du style :
from webdav3.client import Client
WDoptions = {
'webdav_hostname': "https://" + GFServer,
'webdav_login': UsrLogin,
'webdav_password': UsrPass,
'verbose': True
}
WDclient = Client(WDoptions)
WDclient.verify = FalseWDclient.mkdir('/alfresco/webdav/Sites/_Groups/Scans/Cpta/' + trigMag + '/' + trigMag + '_Cpta_FraisG/10-A_Traiter_Cpta')
Pour les espaces l'api est utilisable en s'inspirant de l'exemple ci dessous
def create_subspace(server, authent, mere, fille):
headers = {'Content-Type': "application/json", 'Authorization': "Basic " + authent}
url = "https://" + server + "/api/space/space"
data = {'gid': mere, 'title': fille}
print("create_subspace\t\t", server, " ", fille)
if bShowOnly == True:
# print (headers)
return (1)
else:
# print ("create_subspace\t\tlancement requests.put",server,authent, mere,fille)
content = json.loads(requests.put(url, data=json.dumps(data), headers=headers, verify=False).text)
print("Message")
print(content)
return content['gid']
return (0) -
Votre code de publication de documents via l'api m'intéresse.... si vous pouvez le poster....
-
Pour envoyer un fichier j'utilise Java et ce n'est pas moi qui est fait ce code, mais il reprend le code fourni sur cette page : https://blog.cpming.top/p/httpurlconnection-multipart-form-data
Utilisé comme suit :
try { // Set header Map<String, String> headers = new HashMap<>(); String basicAuth = Base64.getEncoder().encodeToString((goFastLogin+":"+goFastPassword).getBytes()); headers.put("Authorization", "Basic "+basicAuth); logger.info("Conexion à go fast"); HttpPostMultipart multipart = new HttpPostMultipart("https://gofasturl/api/node/node", "utf-8", headers); // Add form field multipart.addFormField("type", "alfresco_item"); multipart.addFormField("title", nomFichier); multipart.addFormField("locations", "[\"" + Path + "\"]"); // Add file multipart.addFilePart("file", fichier, nomFichier); // Print result logger.info("Envoie du fichier"); String response = multipart.finish(); return response; } catch (IOException e) { e.printStackTrace(); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
elle fonctionne très bien.