Im tying to use a REST post to send data from a MS SSIS Process:
json = json + "{ ";
json = json + "\"fields\": {";
json = json + "\"project\": { \"id\": \"XXX\" },";
json = json + "\"summary\": \"REST ye merry gentlemen.\",";
json = json + "\"description\": \"Hellow\",";
json = json + "\"issuetype\": { \"name\": \"Bug\" }";
json = json + "} ";
json = json + "} ";
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://xxx.atlassian.net/rest/api/2/issue/");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
MessageBox.Show(json);
streamWriter.Write(json);
}
string mergedCredentials = string.Format("{0}:{1}", "xxx", "xxx");
byte[] byteCredentials = UTF8Encoding.UTF8.GetBytes(mergedCredentials);
string credentials = Convert.ToBase64String(byteCredentials);
//httpWebRequest.Headers.Add("Authorization", "Basic " + credentials);
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var responseText = streamReader.ReadToEnd();
//Now you have your response.
//or false depending on information in the response
}
The server responds:
SSIS package "Package.dtsx" starting. Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Het doel van een aanroep heeft een uitzondering veroorzaakt. ---> System.Net.WebException: De externe server heeft een fout geretourneerd: (400) Ongeldige opdracht. bij System.Net.HttpWebRequest.GetResponse() bij ST_8fbfe559ee824ef19f7c9bc2c425effc.csproj.ScriptMain.Main() --- Einde van intern uitzonderingsstackpad --- bij System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) bij System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bij System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) bij Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() Task failed: Script Task Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors. SSIS package "Package.dtsx" finished: Failure.
The English bits of the error message are
The purpose of a call has caused an exception. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request