I'm trying to create an issue in JIRA cloud using c# and the REST API, I get the 400 error (bad rquest), I dont know what I'm doing wrong !
This is My functions
public static string PostJsonRequest(string endpoint, string userid, string password, string json)
{
// Create string to hold JSON response
string jsonResponse = string.Empty;
using (var client = new WebClient())
{
try
{
client.Encoding = System.Text.Encoding.UTF8;
client.Headers.Set("Authorization", "Basic " + GetEncodedCredentials(userid, password));
client.Headers.Add("Content-Type: application/json");
client.Headers.Add("Accept", "application/json");
var uri = new Uri(endpoint);
var response = client.UploadString(uri, "POST", json);
jsonResponse = response;
}
catch (WebException ex)
{
// Http Error
if (ex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse wrsp = (HttpWebResponse)ex.Response;
var statusCode = (int)wrsp.StatusCode;
var msg = wrsp.StatusDescription;
// throw new SmtpException(statusCode, msg);
}
else
{
// throw new HttpException(500, ex.Message);
}
}
}
return jsonResponse;
}
And this is my JSON
string json = @"{
'fields':
{
'project':
{
'key':'IS'
},
'summary':'REST Test',
'issuetype':
{
'name':'Bug'
},
}
}";
string Url = "https://XXXXXX.atlassian.net/rest/api/2/issue/";
Any Ideas on what I'm doing wrong ?