curl --request POST \
--url https://api.example.com/api/Productos \
--header 'Content-Type: application/json' \
--data '
{
"nombre": "<string>",
"precio": 123,
"img": "<string>",
"stockActual": 123,
"stockMinimo": 123,
"idCategoria": 123,
"descripcion": "<string>"
}
'{
"idProducto": 123,
"nombre": "<string>",
"precio": 123,
"img": "<string>",
"stockActual": 123,
"stockMinimo": 123,
"idCategoria": 123,
"descripcion": "<string>",
"Categoria": {}
}Create a new product in the catalog
curl --request POST \
--url https://api.example.com/api/Productos \
--header 'Content-Type: application/json' \
--data '
{
"nombre": "<string>",
"precio": 123,
"img": "<string>",
"stockActual": 123,
"stockMinimo": 123,
"idCategoria": 123,
"descripcion": "<string>"
}
'{
"idProducto": 123,
"nombre": "<string>",
"precio": 123,
"img": "<string>",
"stockActual": 123,
"stockMinimo": 123,
"idCategoria": 123,
"descripcion": "<string>",
"Categoria": {}
}Authorization: Bearer {token}
{
"nombre": "Juguete Pelota con Sonido",
"precio": 8.99,
"img": "/images/productos/pelota-sonido.jpg",
"stockActual": 200,
"stockMinimo": 30,
"idCategoria": 3,
"descripcion": "Pelota interactiva con sonido para perros"
}
{
"idProducto": 15,
"nombre": "Juguete Pelota con Sonido",
"precio": 8.99,
"img": "/images/productos/pelota-sonido.jpg",
"stockActual": 200,
"stockMinimo": 30,
"idCategoria": 3,
"descripcion": "Pelota interactiva con sonido para perros",
"Categoria": {
"idCategoria": 3,
"nombre": "Juguetes",
"descripcion": "Juguetes y entretenimiento"
}
}
Location header with the URI of the created resource:
Location: /api/Productos/15
"Error message describing what went wrong"
curl -X POST https://api.huellitas.com/api/Productos \
-H "Authorization: Bearer {your_token_here}" \
-H "Content-Type: application/json" \
-d '{
"nombre": "Juguete Pelota con Sonido",
"precio": 8.99,
"img": "/images/productos/pelota-sonido.jpg",
"stockActual": 200,
"stockMinimo": 30,
"idCategoria": 3,
"descripcion": "Pelota interactiva con sonido para perros"
}'
const nuevoProducto = {
nombre: "Juguete Pelota con Sonido",
precio: 8.99,
img: "/images/productos/pelota-sonido.jpg",
stockActual: 200,
stockMinimo: 30,
idCategoria: 3,
descripcion: "Pelota interactiva con sonido para perros"
};
const response = await fetch('https://api.huellitas.com/api/Productos', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
},
body: JSON.stringify(nuevoProducto)
});
if (response.status === 201) {
const producto = await response.json();
console.log('Producto creado con ID:', producto.idProducto);
}
import requests
nuevo_producto = {
"nombre": "Juguete Pelota con Sonido",
"precio": 8.99,
"img": "/images/productos/pelota-sonido.jpg",
"stockActual": 200,
"stockMinimo": 30,
"idCategoria": 3,
"descripcion": "Pelota interactiva con sonido para perros"
}
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
response = requests.post('https://api.huellitas.com/api/Productos',
json=nuevo_producto,
headers=headers)
if response.status_code == 201:
producto = response.json()
print(f"Producto creado con ID: {producto['idProducto']}")
Huellitas.API/Controllers/ProductosController.cs:50
Entity: Huellitas.Core/Entities/Producto.cs