Posting jira cloud project properties

I am trying to post properties to jira cloud project atlassianHostRestClients.authenticatedAsAddon().postForObject, but getting 405 Method Not Allowed: [no body]. In my atlassian-connect.json i have set "scopes": ["ADMIN"]
Can anyone tell me what the problem might be.

My code is:

String uri = uri.toString() + "https://*******";

        TestToken testToken = new TestToken();
        testToken.Token = "abc";

        return atlassianHostRestClients.authenticatedAsAddon().postForObject(uri, testToken,String.class);

and the TestToken class:

public class TestToken {
    public String testToken;

I have seen this thread but can’t find an answer to my problem.
Ps: All my GET requests are working.

HI TaaviTilgre,
try this one, as described here.

I believe that your test token have to be of type ObjectNode. Try using:
JsonNodeFactory jnf = JsonNodeFactory.instance;
ObjectNode payload = jnf.objectNode();
payload.put(“number”, 5);
payload.put(“string”, “string-value”);

and after that

atlassianHostRestClient.authenticatedAsAddon().postForObject(uri, payload, String.class);

Also important that according to documentation you need WRITE APP SCOPE, keep in mind that i had some problems using admin scope which should include read and write, but some times not working as expected.



I added WRITE to scope ant tried your solution but got the same error.

for more information:
JwtGenerator loggs:

Generating JWT with canonical request: [CanonicalHttpUriComponentsRequest@71612fab method = ‘POST’, relativePath = ‘/rest/api/latest/project/AT/properties’, parameterMap = ‘[]’]

Should parameterMap contain the params i want to add?

And the full error message:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException$MethodNotAllowed: 405 Method Not Allowed: [no body]]

Found the answer: i neded to use

JsonNodeFactory jnf = JsonNodeFactory.instance;
        ObjectNode payload = jnf.objectNode();
            payload.put("string", "string-value");

atlassianHostRestClients.authenticatedAsAddon().put(uri, payload);

(the API didn’t have POST resurse for properties)

1 Like