https://docs.atlassian.com/jira/latest/com/atlassian/jira/avatar/AvatarService.html#setCustomUserAvatar-com.atlassian.jira.user.ApplicationUser-com.atlassian.jira.user.ApplicationUser-java.lang.Long-
setCustomUserAvatar
@ExperimentalApi
void setCustomUserAvatar(ApplicationUser remoteUser,
ApplicationUser user,
Long avatarId)
throws AvatarsDisabledException,
NoPermissionException
Sets a custom avatar for a given user.
Parameters:
remoteUser - a User object for the currently logged in user
user - the user whose avatar we will configure
avatarId - the id of the avatar to configure for the user
Throws:
AvatarsDisabledException - if avatars are disabled
NoPermissionException - if the remote user does not have permission to update the given user's avatar
Since:
v6.0
See Also:
#canSetCustomUserAvatar(com.atlassian.crowd.embedded.api.User, String)
@ExperimentalApi
boolean canSetCustomUserAvatar(ApplicationUser remoteUser,
ApplicationUser user)
Returns a boolean indicating whether the calling user can edit the custom user avatar for the user with the given username.
Parameters:
remoteUser - a User object for the currently logged in user
user - the user whose avatar we will configure
Returns:
a indicating whether the calling user can edit the custom user avatar for another user
Since:
v6.0
http://maffelu.net/jira-basic-cjira-connection-using-rest/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Atlassian;
using Atlassian.Jira;
using System.Net;
using System.IO;
namespace ConsoleApplication14
{
public enum JiraResource
{
project
}
public class JiraManager
{
private const string m_BaseUrl = "http://localhost.:8080/rest/api/latest/";
private string m_Username;
private string m_Password;
public JiraManager(string username, string password)
{
m_Username = username;
m_Password = password;
}
public void RunQuery(
JiraResource resource,
string argument = null,
string data = null,
string method = "GET")
{
string url = string.Format("{0}{1}/", m_BaseUrl, resource.ToString());
if (argument != null)
{
url = string.Format("{0}{1}/", url, argument);
}
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.ContentType = "application/json";
request.Method = method;
if (data != null)
{
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(data);
}
}
string base64Credentials = GetEncodedCredentials();
request.Headers.Add("Authorization", "Basic " + base64Credentials);
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
string result = string.Empty;
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
result = reader.ReadToEnd();
}
Console.WriteLine(result);
}
private string GetEncodedCredentials()
{
string mergedCredentials = string.Format("{0}:{1}", m_Username, m_Password);
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
return Convert.ToBase64String(byteCredentials);
}
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello and welcome to a Jira Example application!");
Console.Write("Username: ");
string username = Console.ReadLine();
Console.Write("Password: ");
string password = Console.ReadLine();
JiraManager manager = new JiraManager(username, password);
manager.RunQuery(JiraResource.project);
Console.Read();
}
}
}