500 Internal Server Error - Confluence Cloud Rest API Call

If I try to make REST API calls in confluence cloud I am getting 500 Internal server error every time.
The same endpoints are working fine if called from the browser after being authenticated.

Is anyone else experiencing this issue?

Thanks!!
Sheff

Hi @designextech,

Which endpoints are you trying to call? Is this via CLI or add-on?

Thanks!

Cheers,
Anne Calantog

1 Like

Hi,

Maybe you should share more info about the error and how you do the rest call that failed.

Thanks

Hi Anne / Sahal,

I am trying to call Get User API
/rest/api/user?key= from the add-on.

I am using atlassian-connect-spring-boot as backend and making API calls using
AtlassianHostRestClients-> authenticatedAsAddon() or authenticatedAsHostActor()

I have following scopes in my atlassian connect descriptor : “READ”,“WRITE”,“PROJECT_ADMIN”,“ADMIN”,“ACT_AS_USER”

What ever I try it always returns 500 Internal Server Error

Thanks!
Sheff

Hi Sahal,

I am trying to call Get User API
/rest/api/user?key= from the add-on.

I am using atlassian-connect-spring-boot as backend and making API calls using
AtlassianHostRestClients-> authenticatedAsAddon() or authenticatedAsHostActor()

I have following scopes in my atlassian connect descriptor : “READ”,“WRITE”,“PROJECT_ADMIN”,“ADMIN”,“ACT_AS_USER”

What ever I try it always returns 500 Internal Server Error

Thanks!
Sheff

Hi,

Maybe you can share your code sample.
What is the detail for the 500 error like stack trace?

The stack trace is not coming back in response.
This is what I get :
org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error

I am using atlassian-connect-sprint boot

https://bitbucket.org/atlassian/atlassian-connect-spring-boot?_ga=2.234729559.835781234.1496347428-1870355731.1485493019

Here is a sample Service code

public class TestService{

@Autowired
private AtlassianHostRestClients atlassianHostRestClients;

public ConfluenceUser getUserProfile(String userKey){
ConfluenceUser user = null;
try{
String url = “/rest/api/user?key=” + userKey + “&expand=details.personal”;
user = atlassianHostRestClients.authenticatedAsHostActor().getForObject(url, ConfluenceUser.class);
}catch (RestClientException exception){
//log error
}catch(Exception error){
//log error
}
return user;
}
}


public class ConfluenceUser {

private String userKey;
private String username;
private String displayName;
private String accountId;

// getter setter properties

}

Thanks!!

Hello Anne,

I noticed another thing ,

  1. If I make a call from browser after being authenticated it works . For e.g
    https://example.atlassian.net/wiki/rest/api/user?key=&expand=details.personal

  2. If I try to make the same call via client (using AP request) or server (using AtlassianHostRestClients.authenticatedAsHostActor().getForObject()),
    it always returns 500 Internal server error

This is the sample code via client

getConfluenceUser(userkey:string){
var url = “/rest/api/user?key=userkey&expand=details.personal”;

return new Promise(function (resolve, reject) {
  try {
    AP.request({
      url: url,
      success: function (response) {
        try {
          console.log(response);
          resolve({});
        } catch (error) {
          console.log(error);
          reject({});   }
      },
      error: function (error) { console.log(error); reject({}); }
    });
  } catch (error) { reject({}); }
});

}

I am not sure if I am missing something. Can you please point me in the right direction.

Thanks!!
Sheff

Hi @designextech,

I’ve replicated your issue. I tried removing some of the scopes and when you remove the PROJECT_ADMIN, I was able to get a response from AP. Refer to Atlassian Scopes for more information.

Thanks!

Cheers,
Anne Calantog

1 Like

Thanks Anne for your help !!

Removing the ‘PROJECT_ADMIN’ scope from atlassian-connect descriptor resolved the issue.

Regards,
Sheff