【发布时间】:2013-08-18 23:29:25
【问题描述】:
我想使用 REST 帖子从 MS SSIS 进程发送数据:
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
}
服务器响应:
SSIS 包“Package.dtsx”正在启动。错误:脚本任务中的 0x1: System.Reflection.TargetInvocationException: Het doel van een aanroep heeft een uitzdering veroorzaakt。 ---> System.Net.WebException: 德 外部服务器 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(对象目标,对象 [] 参数,SignatureStruct& sig,MethodAttributes 方法属性, RuntimeTypeHandle typeOwner) bij System.Reflection.RuntimeMethodInfo.Invoke(对象 obj,BindingFlags invokeAttr、Binder binder、Object[] 参数、CultureInfo 文化、 Boolean skipVisibilityChecks) bij System.Reflection.RuntimeMethodInfo.Invoke(对象 obj,BindingFlags invokeAttr、Binder binder、Object[] 参数、CultureInfo 文化)
bij System.RuntimeType.InvokeMember(字符串名称,BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] 修饰符、CultureInfo 文化、String[] 命名参数) bij Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript() 任务失败:脚本任务警告:包中的 0x80019002:SSIS 警告 代码 DTS_W_MAXIMUMERRORCOUNTREACHED。执行方法成功, 但是引发的错误数 (1) 达到了允许的最大值 (1); 导致失败。当错误数量达到 MaximumErrorCount 中指定的数字。更改 MaximumErrorCount 或修复错误。 SSIS 包“Package.dtsx” 完成:失败。
错误信息的英文位是
调用的目的导致了异常。 ---> System.Net.WebException:远程服务器返回错误:(400) 错误的请求
【问题讨论】:
-
但我不明白为什么会这样,jira 文档指出这是正确的代码:developer.atlassian.com/static/rest/jira/5.2.5.html#id326535