❔ 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 ❤️
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
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?
it's just a standard 400 API response because the json was formatted incorreclty since idk how to properly use this RichText property
what makes you say that?
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
check my stackoverflow question
https://stackoverflow.com/questions/77147203/how-to-implement-the-richtext-field-in-this-simple-c-sharp-library
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...
I just need someone with C# experienceproblem 1: this doesn't really have anything to do with C#
I wish I had more experience in c# :/ but mainly a python guy
you have an HTTP request that's returning an error
stop dodging around the problem and WORK the problem
look at the response
bro u do not understand the problem
and look at the request
then explain it better
you say the request is incorrectly formatted
the HTTP error is BECAUSE I don't understand how to implement this property since they made it a weird IEnumerable variable
how so?
what is the format that is expected?
what is the format that's actually getting sent?
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...
if you refuse to read any of the resources I link you idk what to say @jakenveina
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
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 usedGitHub
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.
okay
neither do I
ok then why are you here? LMFAO
what is the "bad format"
what would be a "correct format"
I need someoen with c# experience who can read that link and tell me how it's meant to be implemented.
right
the interpretation is "there's not enough info here"
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
great
what don't you understand about it?
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
So how do I set this value of RichText so I can change the text of the checkbox as well, not just the IsCheckedNotion API
Start building with the Notion API
Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
you're setting it just fine
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.
right, cause you set
RichText
to an empty listyes, hence my question. When I set RichText to an actual list like
yup
I get the API error malformed request
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
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
it is a normal property
Just a 400 Bad request, malformed response content. Nothing specific.
what does that content look like?
just a flat string?
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
you should pull up something like Wireshark and look at it directly then
i probably shouldnt have given u my api key but whatever
indeed
could you take a look (https://github.com/notion-dotnet/notion-sdk-net/blob/18d3dabba75fa1a1ac72ad0ddca07fd76b5169b2/Src/Notion.Client/Api/Blocks/RequestParams/BlocksUpdateParameters/UpdateBlocks/ToDoUpdateBlock.cs#L14) [at this line]?
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.
as if I haven't already
what about it?
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
yeah, that's very interesting
that's why I'd like to see what the error actually is
or some documentation for the endpoint
ok ill download wireshark and intercept it
I wonder if there's a VS plugin that could make it a little easier....
Notion API
Start building with the Notion API
Connect Notion pages and databases to the tools you use every day, creating powerful workflows.
thats the endpoint
rich_text in the docs is a list so it makes me wonder
right
that matches the
RichText
property being modeled as IEnumerable<T>
in C#yep
BTW
GitHub
notion-sdk-net/Test/Notion.UnitTests/BlocksClientTests.cs at 18d3da...
A Notion SDK for .Net. Contribute to notion-dotnet/notion-sdk-net development by creating an account on GitHub.
so, I think the issue is that you're using
RichTextBaseInput
holy shit
which probably doesn't inculde the "type" property
because that's for the subclasses to define
how tf did u find that i swear i looked eveywhere for exampels
u fucking legend
i love you
all I did was search for
ToDoUpdateBlock
in the codebaselet me delete that github issue so i dont look like a fucking idiot
there's only 2 places it pops up
wow your right I looked at the class definition but somehow didnt see that second result
so, there are multiple types of rich text inputs you can give
all of which inherit from RichTextBaseInput
RichTextTextInput
RichTextEquationInput
RichTextMentionInput
thank you it worked i take back everything i said about you
I definitely recommend continuing to grab Wireshark and looking at that request
yea I should've done that first instead of making a stackoverflow question, github issue, and posting on 4 different discords
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
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.