Web Services Content ID

I’m trying to use the Web services to import items into our Rhythmyx site. I got everything working, but now I’m trying to get the content id of each item that I save, the numbers I’m getting back are something like -665719928530

I can pass this ID to check the items in and it works just fine. But I need the actual content id. The 4 digit number, any ideas?

I’m assuming that the id comes as binary revision-contentid? if so is there a way to extract the content id from it?

I would hope that your content id can be bigger than 4 digits :)…

Are you using the batch importer to import items?

The global ID used in webservices is actually 3 fields mashed together in an unsigned long (64-bit) number. In workbench, you’ll see them a lot in the object inspector.

The fields look something like:
|---- revision ----|- type -|------- object id -------|

Revision: 3 bytes. In general, you’ll use a -1 value, which translates to “not revision specific”. When you are reading data from a content item, this field will have a meaningful value.

Type: 1 byte. For content items, this value will always be 101.

Object Id: 4 bytes. This is the content id of your item.

For content items, you can simply mask off the parts of the ID that you don’t need… you shouldn’t recast to an int as a negative value may cause the content id to become negative too… the best way to get the content id from the returned id is probably something like:

int contentId = (int)(rawId & 0xFFFFFFFFL);

I’ve attached a Java class that may make things a bit simpler and has some more type codes that I’ve been able to decipher if you need them.

If you want more info on types, see the Javadoc for PSTypeEnum

Also, If you want to reuse some of my code, you can check this out.

That package is what I use to bulk-load huge swaths of content from XML feeds (such as RSS).

Is there any way to get the otherway around like from content explorer I need to determine the longid. My requirement is from the content explorer looking at a content item the user will type in the content id in a standalone web page and i need to load the content item.
Thank you.

I found that we can get the long contentid using the FindItems method. I am not sure if its the best way but it works for me.

You can also do (-1L & 0xFFFFFF0000000000L) + (101L << 32) + (long)(contentid).

Might be faster that way than trying to look it up.