Skip to main content
POST
/
upload_file
curl --location 'http://localhost:8080/upload_file' \
--header 'Content-Type: application/json' \
--data '[
  {
    "Clave ": "PROD001",
    "Linea ": "Electronics",
    "Descripción ": "Electronic component",
    "Último costo ": 150.50,
    "Existencias ": 45,
    "Unidad de entrada ": "PCS"
  },
  {
    "Clave ": "PROD002",
    "Linea ": "Accessories",
    "Descripción ": "Accessory item",
    "Último costo ": 75.00,
    "Existencias ": 100,
    "Unidad de entrada ": "PCS"
  }
]'
{
  "msg": "Producto subidos con exito",
  "data": {}
}
This endpoint allows bulk import of products from an Excel file. It processes an array of product objects and validates for duplicate product keys.
This endpoint does NOT require authentication (not secured). It’s directly accessible.

Request Body

The request body should be an array of product objects with the following fields:
Clave
string
required
Unique product key/identifier (note: field name has trailing space)
Linea
string
Product line (note: field name has trailing space)
Descripción
string
Product description (note: field name has trailing space)
Último costo
number
Last cost/price (note: field name has trailing space)
Existencias
number
Stock quantity (note: field name has trailing space)
Unidad de entrada
string
Unit of entry/measurement (note: field name has trailing space)

Response

msg
string
Success message when products are uploaded
data
object
Database operation results
error
string
Error type when upload fails
message
string
Detailed error message
  • “Revise formato de archivo” - Invalid file format
  • “clave duplicada, no se puede insertar” - Duplicate product key
curl --location 'http://localhost:8080/upload_file' \
--header 'Content-Type: application/json' \
--data '[
  {
    "Clave ": "PROD001",
    "Linea ": "Electronics",
    "Descripción ": "Electronic component",
    "Último costo ": 150.50,
    "Existencias ": 45,
    "Unidad de entrada ": "PCS"
  },
  {
    "Clave ": "PROD002",
    "Linea ": "Accessories",
    "Descripción ": "Accessory item",
    "Último costo ": 75.00,
    "Existencias ": 100,
    "Unidad de entrada ": "PCS"
  }
]'
{
  "msg": "Producto subidos con exito",
  "data": {}
}

Error Codes

200
success
Products uploaded successfully
400
error
Bad Request - Invalid file format or duplicate product key
500
error
Internal Server Error - Database operation failed

Implementation Notes

  • The endpoint processes products sequentially (loop at line 32 in cliente.js:32)
  • Each product key is validated using verificar_clave_primary_producto stored procedure (line 33)
  • If a duplicate key is found, the entire operation fails (line 36)
  • Field names have trailing spaces (e.g., “Clave ”, “Linea ”) - ensure exact match
  • An empty string is passed for one field in the insert statement (line 40)
  • This endpoint is NOT secured and does not require authentication

Build docs developers (and LLMs) love