How to POST a null value into a content-type field that has type of Number

My searches:

From what I am reading here the default value should be sent to 0 in this case, and can’t be sent as null. Is this correct? Or is there a way to pass null?

Thanks!

This topic has been created from a Discord post (1255907245687046154) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

The default value for in the database is always null, if you set default value in admin panel

It will be handled by admin panel only

So if you don’t set some value doing POST request I will be null

Or throw validation error

So the post request currently has this following logic when creating the request to send:

seamHeight: ss_test?.seamHeight ?? null

I am unsure how to not set some value when sending this POST request. Do you have any suggestions?

Just use undefined

But that’s legit

It’s going to be null

Unless it set mandatory

Let me try it real fast and see if it’ll go with undefined

Then it will throw error

If it throws then the proper solution is to remove validation in admin

Hmm, looks like using undefined got me a new error instead.

*These fields are not set to mandatory

Lets discuss in one hour in Open Office Hours :smile:

Update

You can POST a null value into a content-type field that has type of Number. There are no issues with this.

The reason I was seeing this error was because the field seamHeight was set to type: “integer” and there was an instance of one of the values I was passing in being a decimal.

As for the other error I saw referenced in my comment above this it was because I broke my Strapi Admin panel and needed to restart it before doing the POST request.

The error obviously pointed me in the wrong direction, and maybe that’s worth looking into, but I got it working with just updating the content-type field seamHeight to type: “decimal”.

Red herring errors are annoying but glad you’ve got it sorted.
I was going to chip in and confirm you can, but it’s always good to peer code through these kinds of things.
Happy you got there in the end!

If you do have any question or want to share code, open office hours runs twice daily 5 days a week.

I’ll be there today! :slightly_smiling_face: