Contentful problem version [Answered]
i'm trying to activate my content type. When i run my code i get this error. Anyone can help?
72 Replies
this is my code
Using the Management API with Contentful and .NET
This article details how to use the management api using the .NET client library | Setting up your first request | Working with content types and entries
i did this
blindly guessing, but i would assume that
client.CreateOrUpdateContentType(...)
will return some data structure which gives ya the new content type version and because u r using the old version it complains.
what's its return type?i don't needs to return anything
it just needs to active my contentType
if i don't active it it stays draft
so i need to active is
it
yeah, but u r either creating or updating the content type, thus it's version will probably change.
and on trying to activate it, its complaining that the version doesnt match.... so most likely the fault lies in the wrong
version
parameterbut the thing is
to create a contenttype i don't need to specify a version
its only when i want to activate it
thats why im asking what that call returns
if its giving ya a new version, then u should use that
you mean
what this peace of code returns?
yep
just a second
when i do a console.writline
i get no error
this is the output
so yeah
so yeah that is the reutn value
the
Contentful.Core.Models.ContentType
type has a SystemProperties
member, which has a Version
member, try to provide that one for the activationoh yeah
something like this
⤴️
??
still the error
this error is so strang
it thinks that someone else is editing something
does ur code look like this right now?
if not please share urs
no i removed the var
but i can try your code
that chunk of code doesnt make any sense, u first try to activate something that might not exist yet, then u either create it or update it (which will then still not be activated)
yeah i see
but
red line
hahahaha
good that u dont provide the error message to make it harder for us to help u .....
lol
oh, then try adding a
!
add the end: ....SystemProperties.Version!
do u know the difference between int?
and int
?nope
the first is nullable, the latter not
it worked
thx man
you are a legend
this is the final code
perfect
result.SystemProperties.Version!
didnt work? or didnt u just try?
because the latter would be more expressivedidn't work
what was the error?
so i just did the quik fix
hahaha
aaah, yeah the
!
was indeed wrongbut
if i do it so than there is no yellow line
now there is
so yeah
!
tells the compiler basically "at this point this nullable value can not be null, the (int)
then just is a castahh
u could have also written
....Version!.Value
i guessah ok
but thx alot for solving my problem
semantically u surely have a version at that point, because u either created it or updated it
yeah yeah
im not sure about this but in my opinion
...Version!.Value
would be more expressive than the (int)
cast
and please close ur open but answered threads with /close
(didnt do it for #Powershell result to c [Answered] and #filter System.string [Answered] either)basically that:
@EliasGPS ⤴️
ohh ok
✅ This post has been marked as answered!