Vous pouvez faire des appels API depuis n'importe quel langage de programmation.
En bash et PHP vous pouvez utiliser curl, en JS vous pouvez utiliser fetch. En Java il y a le paquet HttpUrlConnection. Et en Python il y a le http.client : https://docs.python.org/3/library/http.client.html
Par exemple pour la requête du premier exemple, où l'utilisateur "adm" veut ajouter au document n°586 l'emplacement de son espace personnel, en curl on aurait ceci :
curl -X POST -H "Content-Type: application/json" -d '{"nid": 586, "locations": ["/Sites/_adm"]}' -u "adm:mypassword" http://gofast-demo.ceo-vision.com/api/node/locations
et en python on aurait quelque chose comme ça (pas du tout expert en python donc possiblement approximatif) :
import http.client import json # Set the request parameters url = "gofast-demo.ceo-vision.com" endpoint = "/api/node/locations" payload = {"nid": 586, "locations": ["/Sites/_adm"]} headers = {"Content-Type": "application/json"} username = "adm" password = "mypassword" # Encode the username and password in base64 auth = f"{username}:{password}" encoded_auth = auth.encode("utf-8") b64_auth = base64.b64encode(encoded_auth).decode("utf-8") # Create an HTTP connection conn = http.client.HTTPConnection(url) # Make the POST request conn.request("POST", endpoint, json.dumps(payload), headers={"Authorization": f"Basic {b64_auth}", **headers}) # Get the response response = conn.getresponse() # Print the response status and body print(f"Response Status: {response.status} {response.reason}") print("Response Body:") print(response.read().decode("utf-8")) # Close the connection conn.close()bref, tous les chemins mènent à Rome 😉
Bien à vous,
Raphaël.