cancel
Showing results for 
Search instead for 
Did you mean: 

SAP BAS CAPM debugging via request.https

0 Kudos

Hi ,

In my CAPM Project leveraging sqlite db ,i have implemented UPDATE statement but somehow below (Myservice.js) one is not working. Hence i try to debug this in SAP BAS using request.https script file - I clicked on Send Request(in script file) its showing error "Header name must be a valid HTTP token ["post https"]".

So can you please help me on this.

request.https:

Send Request

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;}

Accepted Solutions (1)

Accepted Solutions (1)

martinstenzig
Contributor
0 Kudos

I tried to reproduce your problem. It seems like you explicitly have the "Send Request" as string in your file. You need to take that out. The tooling (rest client) will show "Send Request" hovering above your HTTP request. Once you click on that you get the proper behavior. I tried your URL, but received a 404

0 Kudos

Thanks Martin now i able to Send Request.

Facing one more issue , when i send the request - am getting response as attached , due to this i unable to debug. Can you please help to fix this one also.

HTTP/1.1 401 Unauthorised

responseissue.png

martinstenzig
Contributor
0 Kudos

amitavghose do you still have this problem? I assume you are using Business Application Studio? Did you enable the forwarding of the localhost to the external address?

0 Kudos

its resolved Martin.

Answers (0)