Umbraco 15 - Management API, creating new node

Hi,
I’m trying to connect to the Management API and create a new node in the backoffice via Postman.
I’ve got postman setup, I can call
umbraco/management/api/v1/document but I’m getting a mix of errors, probably due to something I’m missing.

{
  "documentType": {
    "id": "<uuid>"
  },
  "template": {
    "id": "<uuid>"
  },
  "values": [
    {
      "alias": "<string>",
      "culture": "<string>",
      "segment": "<string>",
      "value": {
        "nullable": true
      }
    },
    {
      "alias": "<string>",
      "culture": "<string>",
      "segment": "<string>",
      "value": {
        "nullable": true
      }
    }
  ],
  "variants": [
    {
      "name": "<string>",
      "culture": "<string>",
      "segment": "<string>"
    },
    {
      "name": "<string>",
      "culture": "<string>",
      "segment": "<string>"
    }
  ],
  "id": "<uuid>",
  "parent": {
    "id": "<uuid>"
  }
}

This is the template that I have for my Postman Post, now, I’m hoping not all of this is required but also I’m not sure what is required.

My guesses so far are :

  "documentType": {
    "id": "<uuid>"
  },
  "template": {
    "id": "<uuid>"
  },

This is the documentType uuid that I am wanting to create, for example, what ever UUID I have for my document type BlogPost.
The template UUID is the template that is associated with this document type.

values": [
    {
      "alias": "<string>",
      "culture": "<string>",
      "segment": "<string>",
      "value": {
        "nullable": true
      }
    },
    {
      "alias": "<string>",
      "culture": "<string>",
      "segment": "<string>",
      "value": {
        "nullable": true
      }
    }

Alias is maybe something like aNewBlogPost or something similar that would be unique each time a post is created. Culture would be en-US if that’s the default language setup on the site. Segment, I have no idea.

 "variants": [
    {
      "name": "<string>",
      "culture": "<string>",
      "segment": "<string>"
    },
    {
      "name": "<string>",
      "culture": "<string>",
      "segment": "<string>"
    }
  ],
  "id": "<uuid>",
  "parent": {
    "id": "<uuid>"
  }

If I don’t have variants, do I even need this info?

Id, is that just a new Guid that is needed for this new node, parent is presumably the parent id where this node is going to be saved?

So my question I guess is, what do I need and not need so that I can create a document in the backoffice via the Management API :slight_smile:

I don’t have any answers to most of your questions (never tried) but in Umbraco itself you only need to put in a node title, I’d think the same would go for an API version. That said, the doctype is already set when you click in the backoffice, so you’d need that Id and you’d need a parent node Id as well I would think. Template might be automatic.

Anyway, try it out, remove more and more params until it breaks, that’s how I’d start :sweat_smile:

1 Like

Maybe you can just create a node in the backoffice and see what the payload of that call is.

2 Likes

Never even thought of that. Thanks!

The payload looks to have all the info I might need.

1 Like

Just to confirm, that worked perfectly.

The payload looks like this :

{"id":"df985aee-7b7c-4d2b-a343-67d3e0ab05c2", // Unique Guid for each post
"parent":null,
"documentType":
{"id":"2ecd6511-f8b1-469e-a1ff-cfc141397c7a"},  // UUID of the Doctype
"template":null,
"values":
[
    {
    "editorAlias":"Umbraco.TextBox",
    "alias":"title",
    "culture":null,
    "segment":null,
    "value":"test" // Value for the textbox that's on the DocType
    }
    ],
    "variants":
    [
        {
            "culture":null,
            "segment":null,
            "state":null,
            "name":"Test Blog Post", // Title of the Blog
            "publishDate":null,
            "createDate":null,
            "updateDate":null
            }
            ]
           }

I’ve added a couple of comments to help anyone else that might stumble on this. :slight_smile:

2 Likes

Do you make up the new post guid on the fly or is that fetched from the api somehow initially?

I’ll make one on the fly. For the Postman experiment I manually changed the guid and it worked fine.

1 Like