Skip to Content
1
Nov 25, 2019 at 08:48 AM

Issue with creating entity with integers (SAP Cloud SDK NodeJS)

4700 Views

Hello all,

While prepping my test cases for #sitNL I ran into an issue with Entities who have INT32 values.

I build an App with CAP with the default Bookshop model and implemented the v2 proxy to have a working v2 service.

Downloaded that V2 metadata.xml and ran it through the generator to have my model.

So I wanted to create a Book:

const entry = Books.builder()
    .id(1)
    .title("Practical VIM")
    .stock(999)
    .authorId(201)
    .build();

Books.requestBuilder()
    .create(entry)
    .execute({ url: "http://localhost:3001" })
    .then(async output => {
        await console.log(output);
    });

And when I ran it, my server gave an error that Strings aren't supported for INT values.

After some debugging I found in the deserializer from the payload-value-converter in the cloud-sdk-core, that it was converting my value to a String ('Edm.Int32': toString). After adding a new function that always converted the int32 to an Integer value it worked again.

Was I missing anything or is this function not working correctly for INT32 values at this moment?