Hi @ianRagudo, Below are code snippets I am using
putData(ConfigurationManager.AppSettings[âJiraBaseUrlâ], â/rest/api/2/issue/â + 68658, âoverrideScreenSecurity=true¬ifyUsers=falseâ, customValue);
public void putData(string baseUrl, string apiPath, string queryString, string data)
{
string token = generatePayLoad(âPUTâ, baseUrl, apiPath, queryString);
var stringContent = new StringContent(data, Encoding.UTF8, âapplication/jsonâ);
using (var httpClient = new HttpClient { BaseAddress = new Uri(baseUrl) })
{
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(âapplication/jsonâ));
httpClient.DefaultRequestHeaders.TryAddWithoutValidation(âAuthorizationâ, "JWT " + token);
using (var response = httpClient.PutAsync(apiPath + "?" + queryString, stringContent).Result)
{
string resp = response.Content.ReadAsStringAsync().Result;
}
}
}
public string generatePayLoad(string method,string baseUrl, string apiPath,string queryString)
{
var unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
long issuedAt = (long)Math.Round((DateTime.UtcNow - unixEpoch).TotalSeconds);
long expiresAt = issuedAt + 3600L;
string canonical_request = method + â&â + apiPath + â&â + queryString;
string signed_canonical_requestByte = getQSH(canonical_request);
var payload = new Dictionary<string, object>()
{
{ âqshâ, signed_canonical_requestByte},
{ âissâ, âcom.FactSet.JIRAIntegrationsâ },
{ âiatâ, issuedAt },
{ âexpâ, expiresAt },
};
IJwtAlgorithm algorithm = new HMACSHA256Algorithm();
IJsonSerializer serializer = new JsonNetSerializer();
IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();
IJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);
return encoder.Encode(payload, jwtToken);
}
static string getQSH(string qstring)
{
System.Security.Cryptography.SHA256Managed crypt = new System.Security.Cryptography.SHA256Managed();
StringBuilder hash = new StringBuilder();
byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(qstring));
foreach (byte theByte in crypto)
{
hash.Append(theByte.ToString("x2"));
}
return hash.ToString();
}
Let me know if I need to provide any other info