我想使用 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 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[] 参数, CultureInfo 文化, Boolean skipVisibilityChecks) bij System.Reflection。
bij System.RuntimeType.InvokeMember(字符串名称,BindingFlags bindingFlags,Binder binder,Object 目标,Object[] providedArgs,ParameterModifier[] 修饰符,CultureInfo 文化,String[] namedParams) bij Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine。 ExecuteScript() 任务失败:脚本任务警告:包中的 0x80019002:SSIS 警告代码 DTS_W_MAXIMUMERRORCOUNTREACHED。Execution 方法成功,但引发的错误数 (1) 达到了允许的最大值 (1);导致失败。当错误数量达到 MaximumErrorCount 中指定的数量时,就会发生这种情况。更改 MaximumErrorCount 或修复错误。SSIS 包“Package.dtsx”完成:失败。
错误消息的英文位是
调用的目的导致了异常。---> System.Net.WebException: 远程服务器返回错误: (400) Bad Request