C
C#15mo ago
burn

❔ How do I implement this property?

I'm trying to use a C# Notion API wrapper, I've got my code working but for the love of god I cannot figure out how to implement this RichText property. It's an IEnumerable so I thought this would work but I got a 400 bad request from the API so I don't think this is how the authors meant for it to be used. Could someone take a quick look at the GitHub and help me understand? Tysm ❤️
RichText = new List<RichTextBaseInput>() { new RichTextBaseInput()
{
PlainText = "shouldn't this work?"
} },
RichText = new List<RichTextBaseInput>() { new RichTextBaseInput()
{
PlainText = "shouldn't this work?"
} },
GitHub
notion-sdk-net/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpd...
A Notion SDK for .Net. Contribute to notion-dotnet/notion-sdk-net development by creating an account on GitHub.
67 Replies
JakenVeina
JakenVeina15mo ago
what endpoint is giving you a 400? what is the response? where is that endpoint documented? what's the JSON that you end up sending?
burn
burnOP15mo ago
it's just a standard 400 API response because the json was formatted incorreclty since idk how to properly use this RichText property
JakenVeina
JakenVeina15mo ago
what makes you say that?
burn
burnOP15mo ago
because the API request worked just fine when the new List<RichTextBaseInput>() was uninitialized and empty, but the text didn't actually update to anything since there was no value. I just need someone with C# experience to tell me how to implement that property properly, unfortunately there is no documentation cause it's supposed to be a rather simple library
burn
burnOP15mo ago
Stack Overflow
How to implement the RichText field in this simple C# library
I'm trying to use the C# Notion API library but I feel really dumb right now. I'm updating a ToDo block which I have done successfully with this code ToDoUpdateBlock requestParams = new ToDoUpdate...
JakenVeina
JakenVeina15mo ago
I just need someone with C# experience
problem 1: this doesn't really have anything to do with C#
burn
burnOP15mo ago
I wish I had more experience in c# :/ but mainly a python guy
JakenVeina
JakenVeina15mo ago
you have an HTTP request that's returning an error stop dodging around the problem and WORK the problem look at the response
burn
burnOP15mo ago
bro u do not understand the problem
JakenVeina
JakenVeina15mo ago
and look at the request then explain it better you say the request is incorrectly formatted
burn
burnOP15mo ago
the HTTP error is BECAUSE I don't understand how to implement this property since they made it a weird IEnumerable variable
JakenVeina
JakenVeina15mo ago
how so? what is the format that is expected? what is the format that's actually getting sent?
burn
burnOP15mo ago
GitHub
Why is the RichText property an IEnumerable? How am I supposed to i...
I'm trying to update a To-do block and I've done so successfully but I'm struggling to assign RichText an actual value and understand the code/why the RichText property is an IEnumerabl...
burn
burnOP15mo ago
if you refuse to read any of the resources I link you idk what to say @jakenveina
JakenVeina
JakenVeina15mo ago
they all say the same thing that your post started with they all yield the same question what is the error being returned by the API if you're confident that the request is malformed, let's LOOK at it and then tell me how that's wrong and I can tell you how the code that you wrote isn't generating what you expect, and what the proper code would be as it stands, I don't know what your end result is supposed to be ergo, I have no way to tell you how to get there
burn
burnOP15mo ago
the error being returned by the API is a bad format BECAUSE I don't know how the authors intended for this public IEnumerable<RichTextBaseInput> RichText { get; set; } property to be used
GitHub
notion-sdk-net/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpd...
A Notion SDK for .Net. Contribute to notion-dotnet/notion-sdk-net development by creating an account on GitHub.
JakenVeina
JakenVeina15mo ago
okay neither do I
burn
burnOP15mo ago
ok then why are you here? LMFAO
JakenVeina
JakenVeina15mo ago
what is the "bad format" what would be a "correct format"
burn
burnOP15mo ago
I need someoen with c# experience who can read that link and tell me how it's meant to be implemented.
JakenVeina
JakenVeina15mo ago
right the interpretation is "there's not enough info here"
burn
burnOP15mo ago
Ok, well considering the other 140 people who starred the library and used all these classes without any docs the source code should be enough information, but I can't understanad this one property hence this question
JakenVeina
JakenVeina15mo ago
great what don't you understand about it?
burn
burnOP15mo ago
NotionClient.Blocks.UpdateAsync(blockID, requestParams); this is the function I'm calling. It works when I create a ToDoUpdateBlock object like this and intialize it's property with an EMPTY List<RichTextBaseInput>. I can change a checkbox from not checked to checked, great. But I'm also trying to change the text of the checkbox [Rich text] (https://developers.notion.com/reference/rich-text) as referenced by the API here
ToDoUpdateBlock requestParams = new ToDoUpdateBlock()
{
ToDo = new ToDoUpdateBlock.Info()
{
RichText = new List<RichTextBaseInput>(),
IsChecked = true
}
};
ToDoUpdateBlock requestParams = new ToDoUpdateBlock()
{
ToDo = new ToDoUpdateBlock.Info()
{
RichText = new List<RichTextBaseInput>(),
IsChecked = true
}
};
So how do I set this value of RichText so I can change the text of the checkbox as well, not just the IsChecked
Notion API
Start building with the Notion API
Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
JakenVeina
JakenVeina15mo ago
you're setting it just fine
burn
burnOP15mo ago
It's empty. When I run my code the checkbox goes from not checked to check but the actual text beside it doesn't change.
burn
burnOP15mo ago
No description
JakenVeina
JakenVeina15mo ago
right, cause you set RichText to an empty list
burn
burnOP15mo ago
yes, hence my question. When I set RichText to an actual list like
RichText = new List<RichTextBaseInput>() { new RichTextBaseInput()
{
PlainText = "shouldn't this work?"
}},
RichText = new List<RichTextBaseInput>() { new RichTextBaseInput()
{
PlainText = "shouldn't this work?"
}},
JakenVeina
JakenVeina15mo ago
yup
burn
burnOP15mo ago
I get the API error malformed request
JakenVeina
JakenVeina15mo ago
and you're assuming that the reason for that error is that you're misusing C# somehow you're not so, we circle back to my original question: what does the actual response say
burn
burnOP15mo ago
so it comes down to how do I set this property properly like the authors intended? I don't understand why they even made it an IEnumerable when it makes more sense to make it a normal property
JakenVeina
JakenVeina15mo ago
it is a normal property
burn
burnOP15mo ago
Just a 400 Bad request, malformed response content. Nothing specific.
JakenVeina
JakenVeina15mo ago
what does that content look like? just a flat string?
burn
burnOP15mo ago
this is the most info I get from the request/response. their libraries logging is really dumb it doesn't show u the actual json being sent in the request body
JakenVeina
JakenVeina15mo ago
you should pull up something like Wireshark and look at it directly then
burn
burnOP15mo ago
i probably shouldnt have given u my api key but whatever
JakenVeina
JakenVeina15mo ago
indeed
JakenVeina
JakenVeina15mo ago
as if I haven't already what about it?
burn
burnOP15mo ago
I just don't understand. IEnumerable<RichTextBaseInput> is the type for the property but then when I pass in a list of RichTextBaseInput it doesn't work?? Like
JakenVeina
JakenVeina15mo ago
yeah, that's very interesting that's why I'd like to see what the error actually is or some documentation for the endpoint
burn
burnOP15mo ago
ok ill download wireshark and intercept it
JakenVeina
JakenVeina15mo ago
I wonder if there's a VS plugin that could make it a little easier....
burn
burnOP15mo ago
Notion API
Start building with the Notion API
Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
burn
burnOP15mo ago
thats the endpoint rich_text in the docs is a list so it makes me wonder
JakenVeina
JakenVeina15mo ago
right that matches the RichText property being modeled as IEnumerable<T> in C#
burn
burnOP15mo ago
yep
JakenVeina
JakenVeina15mo ago
BTW
JakenVeina
JakenVeina15mo ago
so, I think the issue is that you're using RichTextBaseInput
burn
burnOP15mo ago
holy shit
JakenVeina
JakenVeina15mo ago
which probably doesn't inculde the "type" property because that's for the subclasses to define
burn
burnOP15mo ago
how tf did u find that i swear i looked eveywhere for exampels u fucking legend i love you
JakenVeina
JakenVeina15mo ago
all I did was search for ToDoUpdateBlock in the codebase
burn
burnOP15mo ago
let me delete that github issue so i dont look like a fucking idiot
JakenVeina
JakenVeina15mo ago
there's only 2 places it pops up
burn
burnOP15mo ago
wow your right I looked at the class definition but somehow didnt see that second result
JakenVeina
JakenVeina15mo ago
so, there are multiple types of rich text inputs you can give all of which inherit from RichTextBaseInput RichTextTextInput RichTextEquationInput RichTextMentionInput
burn
burnOP15mo ago
No description
burn
burnOP15mo ago
thank you it worked i take back everything i said about you
JakenVeina
JakenVeina15mo ago
I definitely recommend continuing to grab Wireshark and looking at that request
burn
burnOP15mo ago
yea I should've done that first instead of making a stackoverflow question, github issue, and posting on 4 different discords
JakenVeina
JakenVeina15mo ago
that definitely ought to be an easier thing to do in .NET development, but the issue would have been obvious if you had been able to lay eyes on the JSON being sent, at any point
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server