Avalados por :

Solución de error de encabezado HTTP al actualizar datos en SAP BAS con SQLite y CAPM

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 5 Vistas
0
Loading...

Hola,

En mi proyecto CAPM utilizando la base de datos sqlite, he implementado una declaración de ACTUALIZACIÓN pero de alguna manera la siguiente (Myservice.js) no está funcionando. Por lo tanto, intento depurar esto en SAP BAS utilizando el archivo de script request.https: al hacer clic en Enviar solicitud (en el archivo de script) muestra el error "El nombre del encabezado debe ser un token HTTP válido ["post https"]".

Así que ¿puedes ayudarme con esto, por favor?

request.https:

Enviar solicitud

POST https://port4004-workspaces-ws-6hqg8.us10.trial.applicationstudio.cloud.sap/srv/CatalogService/Categ...

Content-Type: application/json

{ "ID":3, "PRODUCTID": 3, "PRODUCTNAME": "Aniseed Syrup", "QUANTITYPERUNIT": "12 - 550 ml bottles", "UNITPRICE": 10, "UNITSINSTOCK": 15, "UNITS":15 }

Myservice.js:

module.exports = (srv) => {
const {Product} = cds.entities ('my.product') srv.before ('UPDATE', 'Category', async (req) => { const category = req.data if (!category.UNITS || category.UNITS <= 0) return req.error (400, 'Units in stock should be greater than zero') const tx = cds.transaction(req) const affectedRows = await tx.run ( UPDATE (Product) .set ({ UNITSINSTOCK : {'=': category.UNITS }}) .where ({ PRODUCTID: {'=': category.PRODUCTID}}) ) if (affectedRows === 0) req.error (409, "No Product available, sorry") })
}

Myservice.cds:using {my.product as my } from '../db/product';@path: 'srv/CatalogService'service MyService { entity Product as projection on my.Product; entity Category @updateonly as projection on my.Category;}

Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

4 Respuestas

0
Loading...

Se resolvió, Martín.

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Loading...

amitavghose ¿Todavía tienes este problema? ¿Supongo que estás utilizando Business Application Studio? ¿Habilitaste el reenvío del localhost a la dirección externa?

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Loading...

Gracias Martin, ahora puedo enviar la solicitud.

Enfrentando otro problema, cuando envío la solicitud, recibo la respuesta adjunta, debido a esto no puedo depurar. ¿Puedes ayudarme a solucionar este también?

HTTP/1.1 401 No autorizado

responseissue.png

responseissue.png
Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Loading...

Intenté reproducir tu problema. Parece que tienes explícitamente la frase "Send Request" en tu archivo. Necesitas quitar eso. La herramienta (cliente REST) mostrará "Send Request" flotando sobre tu solicitud HTTP. Una vez que hagas clic en eso, obtendrás el comportamiento adecuado. Intenté acceder a tu URL, pero recibí un error 404.

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?