Always receive 405 when trying to create content

Hello,
I am trying to create content in my strapi instance but no matter what I do I always get Method not allowed.

This is the code:

await this.client.axios.post(
      `${this.config.baseUrl}/api/device-information`,
      {
        name: 'test',
        descriptionShort: 'test test',
        descriptionLong: 'testetet',
        category: 'testcategory',
        productNumber: 323,
        imgage: imageId,
      },
      {
        headers: {
          Authorization: `Bearer ${this.config.token}`,
        },
      },
    );
  • I successfully upload the image using same this.config.baseUrl and token and imageId is the correct id.
  • I also double checked the permission of the API key, and it has full permission to create on this content type.
  • I also double checked all the attributes and if the API id of the content type is device-information
  • the this.config.baseUrl is in the form of http://xx.xx.xxx.xxx:1337
  • and yes I realized that there is a typo in imgage
    What am I missing?

Hello. and welcome to the Strapi community forums @zoiman :wave: :cake:
Can I ask is this a single type or a collection type :slight_smile:

it is a collection type

Ok thank you, though isn’t a collection type a plural ending?
/api/device-informations

hm when I use the plural API ID I get a 400 :thinking:

Alright, and you gave it permissions to create in the User & Permissions > Authenticated as well ? :slight_smile:

I gave it permission directly in the API Tokens.
But I now also add this:

and I still get a 400.
I think the request somehow is not correct. Is it correct to only send the id of the image or does this maybe need to be wrapped in an object of some kind?

I also changed the type of productNumber to a string since the type is Text. This is how the collection type looks like:

hm I still can not figure this out… anyone any suggestions?

Hello, you should use API ID (Plural) making your requests. In first message you have used

${this.config.baseUrl}/api/device-information

but on the screen from admin panel you have device-informations in API ID (Plural) field. In your API requests use

${this.config.baseUrl}/api/device-informations

API ID (Plural) misspelling also will cause this “Method Not Allowed” issue.
Good luck!