Error 405 when trying to create a user group

Mehdi June 23, 2021

 

AP.request({ 
url: "/rest/api/group",
type: 'PUT',
contentType: "application/json",
Accept: 'application/json',
Authorization: "Basic bWJvdWF6emEuc3BlY3RydW1ncm91cGVAZ21haWwuY29tOk9jQjloZXRCWVg1b2dDaDdtUXNSMDRCNA==",                    data: JSON.stringify(bodyData2),
     success: function (data) {
console.log(data)
}}).catch(function (error) {
console.log(error)
});

I added to scope all permissions 

"scopes": [    "READ",    "ACT_AS_USER",    "WRITE",    "DELETE",    "SPACE_ADMIN",    "ADMIN"  ],

 im connected with an administrator

2 answers

0 votes
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2021

Hello @Mehdi 

A 405 error is telling you that the request is incorrectly formed, which means your code which is making the request has a mistake in it.

Try doing some basic testing of the structure of the request first, using a REST API test tool like Postman. If the request works, then some other part of your code is incorrect.

0 votes
Niranjan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 23, 2021

Hi @Mehdi - Can you check the URI format?

New group creation must have a POST /wiki/rest/api/group

https://developer.atlassian.com/cloud/confluence/rest/api-group-group/#api-api-group-post

User must be a site admin to create a new group

Mehdi June 26, 2021

hi @Niranjan , sorry i put the wrong code

this is my code 

const bodyData2 = {"name": "RS-managers"};
AP.request({ url: "/rest/api/group",
type: 'PUT',
contentType: "application/json",
Accept: 'application/json',
Authorization: "bWJvdWF6emEuc3BlY3RydW1ncm91cGVAZ21haWwuY29tOnd6UGhpRXBWd1JTN0E0aDhrRVRyODhGRg==",
data: JSON.stringify(bodyData2),
success: function (data) {console.log(data)}
}).catch(function (error
console.log(error)        
});
Niranjan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 26, 2021

@Mehdi - Can you try with POST method ? PUT method is generally used for update.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events