Establece el valor de una clave en una colección. El comodín * en la ruta se reemplaza con el nombre de la clave.
Requiere autenticación interna. Pasa las credenciales mediante el encabezado X-Glue-Authentication, o los encabezados apikey y secret.
curl -X POST "https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001" \
-H "X-Glue-Authentication: TU_TOKEN_AUTH" \
-H "Content-Type: application/json" \
-d '{
"value": {
"name": "Alicia",
"email": "alicia@example.com",
"role": "admin"
}
}'
POST /v1/collections/usuarios/keys/usuario:1001 HTTP/1.1
Host: api.hola.cloud
X-Glue-Authentication: TU_TOKEN_AUTH
Content-Type: application/json
{
"value": {
"name": "Alicia",
"email": "alicia@example.com",
"role": "admin"
}
}
package main
import (
"fmt"
"io"
"net/http"
"encoding/json"
"strings"
)
func main() {
payload := map[string]any{"value": map[string]any{"email": "alicia@example.com", "name": "Alicia", "role": "admin"}}
bodyBytes, err := json.Marshal(payload)
if err != nil {
panic(err)
}
body := string(bodyBytes)
req, err := http.NewRequest("POST", "https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001", strings.NewReader(body))
if err != nil {
panic(err)
}
req.Header.Set("X-Glue-Authentication", "TU_TOKEN_AUTH")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println(string(responseBody))
}
<?php
$payload = ['value' => ['email' => 'alicia@example.com', 'name' => 'Alicia', 'role' => 'admin']];
$body = json_encode($payload);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => [
'X-Glue-Authentication: TU_TOKEN_AUTH',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
echo $response;
import requests
import json
headers = {
"X-Glue-Authentication": "TU_TOKEN_AUTH",
"Content-Type": "application/json",
}
payload = {"value": {"email": "alicia@example.com", "name": "Alicia", "role": "admin"}}
body = json.dumps(payload)
response = requests.request(
"POST",
"https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001",
headers=headers,
data=body
)
print(response.text)
const payload = {"value": {"email": "alicia@example.com", "name": "Alicia", "role": "admin"}};
const response = await fetch("https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001", {
method: "POST",
headers: {
"X-Glue-Authentication": "TU_TOKEN_AUTH",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
console.log(await response.text());
const payload = {"value": {"email": "alicia@example.com", "name": "Alicia", "role": "admin"}};
const response = await fetch("https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001", {
method: "POST",
headers: {
"X-Glue-Authentication": "TU_TOKEN_AUTH",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
});
const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;
public class Main {
public static void main(String[] args) throws Exception {
var payload = Map.of("value", Map.of("email", "alicia@example.com", "name", "Alicia", "role", "admin"));
var body = new ObjectMapper().writeValueAsString(payload);
var request = HttpRequest.newBuilder()
.uri(URI.create("https://api.hola.cloud/v1/collections/usuarios/keys/usuario:1001"))
.method("POST", HttpRequest.BodyPublishers.ofString(body))
.header("X-Glue-Authentication", "TU_TOKEN_AUTH")
.header("Content-Type", "application/json")
.build();
var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Comentarios