kiota: TypeScript bug - Create message request returns bad request error

Testing code:

const userRequestBuilder = client.usersById("ID");
const messagesRequestBuilder = userRequestBuilder.messages;
const message = new Message();
message.subject = "test subject";
const post = await messagesRequestBuilder.post(message);

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28 (28 by maintainers)

Most upvoted comments

Creating a separate issue #1013 to discuss more about interfaces vs classes as this discussion is not related to this present issue.

+1 to what @sebastienlevert said. new Message() doesn’t seem like anything I’ve ever seen in JavaScript. It’s intuitive in C#, but not in JavaScript. Rather than imposing a specific usage patterns on developers, we should see if there are other ways for us to implement necessary plumbing while allowing developers to use programming patterns they’re used to.

Definitely, this would add a lot of value here. But, why are we using classes vs Interfaces? Interfaces would allow us to achieve this. There is probably a reason behind this design, so if we can do the partial initializers, this would be a great start. But let’s think in a “JavaScript / TypeScript” way and not in a non-familiar way for developers. If they never used new EmailAddress() in the past, I don’t know if they should in the future, as long as they respect the interface…

Actually, just after writing this, I remember we could do that in TypeScript, maybe this is something we should consider adding to enable the (shorter) second style https://stackoverflow.com/a/37682352/3808675

The only complexity added for developers is for file upload/downloads, everything else is encapsulated to them thanks to the fluent API. For that specific case however, we can perfectly ship utility methods in the variants to help go from a browser blob/nodejs file handle/etc… to the whatever type (union) we end up choosing and make their lives easier.

Am I reading this correctly, that developers using the SDK, will be able to call:

const message = {
    "subject":"Did you see last night's game?",
    "importance":"Low",
    "body":{
        "contentType":"HTML",
        "content":"They were <b>awesome</b>!"
    },
    "toRecipients":[
        {
            "emailAddress":{
                "address":"AdeleV@contoso.onmicrosoft.com"
            }
        }
    ]
};
client.me.messages.post(message);

without having to wrap the message in ArrayBuffer first?

Just to ensure that we’re talking about the same: using ArrayBuffer is not the problem in itself, as long as we don’t require developers to wrap all payloads in it. If we use ArrayBuffer, or anything else internally, that’s our design decision.