zoiman
March 23, 2023, 9:33am
1
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?
Ok thank you, though isn’t a collection type a plural ending?
/api/device-informations
zoiman
March 23, 2023, 10:06am
5
hm when I use the plural API ID I get a 400
Alright, and you gave it permissions to create in the User & Permissions > Authenticated as well ?
zoiman
March 23, 2023, 10:23am
7
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?
zoiman
March 23, 2023, 10:49am
8
I also changed the type of productNumber to a string since the type is Text
. This is how the collection type looks like:
zoiman
March 24, 2023, 11:53am
9
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!