Strapi 4 create or update

Good afternoon.

In Strapi 4, it is impossible to create or update an element according to the instruction.
Can you update the manual or post it here?

Hi @RomanRRR, you’d need to send the required API requests to Strapi using the HTTP Request node. The API requests itself would be described in Strapi’s documentation, e.g. here for creating an entry.

You’ll need to authenticate your request with an Authorization header having a value of bearer your-api-token from the looks of it. The process of creating a token is described here.

Please give detailed instructions for low optimistic users

Hey @RomanRRR,

It looks like @MutedJam provided an example that would get you started here: Strapi Get All - #13 by MutedJam

Did you run into any issues with that workflow? It would also be worth only replying to one thread instead of posting the same reponse on both just to make it easier to follow.

good afternoon. The thread of the question on the link - there I asked: how to get everything?

In that matter, we were able to get everything. Everything works well.

And in this question - how to update a record by its ID or create a new record in the collection.

Please give detailed instructions.

Hey @RomanRRR,

Using the same example @MutedJam posted the other day you would need to change the second HTTP Request node to POST then set the body to match the data that needs to be sent. Looking at the Strapi API documentation you would need to send the below to create your content.

{
  "data": {
    "title": "Hello",
    "relation": 2,
    "relations": [2, 4],
    "link": {
      "id": 1,
      "type": "abc"
    }
  }
}

For updating it would be the below but the URL would need to include the ID for the item you want to update.

{
  "data": {
    "title": "Hello",
    "relation": 2,
    "relations": [2, 4],
  }
}

This in theory will give you something like the 2 untested workflows below, You will need to make some changes to the URLs, IDs being used and possible some of the data being sent but it should get you on the right track.

Create
Update

thank you very much!
helped a lot

1 Like