It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I have error 400 in c# with API REST Edited

Hello everyone, see if anyone can help me. I want to create an issue from an application in c #, but it returns error 400. I have tested my Json on POSTMAN, and it creates the issue correctly, but in c # I have not managed to work, my code is as follows:

string json = @"{
                                                    'projectTypeKey': 'service'
                                      'summary': 'Esto es una prueba APIREST',
                                      'issuetype': {
                                                        'name': 'SAAxxx'
var userid = "";
var password = "gsfasdfsdfgexample";
var endpoint = @"";



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())
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;
Console.WriteLine(statusCode + " " + msg);

return jsonResponse;



private static string GetEncodedCredentials(string userid, string password)
string mergedCredentials = string.Format("{0}:{1}", userid, password);
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
return Convert.ToBase64String(byteCredentials);

1 answer

1 accepted


Changed the JSON in only one line and quote (")


string json = @"{\"fields\":{\"project\":{\"key\":\"SEExxx\",\"projectTypeKey\": \"service\"},\"summary\": \"Esto es una prueba APIREST\",\"issuetype\": {\"name\": \"SAAxxx'}}}";

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you