如何在 C# 中使用 post 调用 tempoplugin 的添加帐户方法

How to call add account method for tempoplugin with post in C#

this url 中描述了如何使用 post 调用 tempoplugin。为了实现它,我创建了以下字符串:

还为 posting 数据创建了以下代码:

    public static string HTTP_POST(string Url, string Data, string userName = "", string password = "")
    {

        string Out = String.Empty;
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
        try
        {
            if (userName != null && password != null)
            {
                req.ContentType = "application/json";
                req.Method = "POST";
                req.ProtocolVersion = HttpVersion.Version11;

                string base64Credentials = GetEncodedCredentials(userName, password);
                req.Headers.Add("Authorization", "Basic " + base64Credentials);
            }

            req.Timeout = 100000;
            byte[] sentData = Encoding.UTF8.GetBytes(Data);
            req.ContentLength = sentData.Length;
            using (System.IO.Stream sendStream = req.GetRequestStream())
            {
                sendStream.Write(sentData, 0, sentData.Length);
                sendStream.Close();
            }
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            System.IO.Stream ReceiveStream = res.GetResponseStream();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8))
            {
                Char[] read = new Char[256];
                int count = sr.Read(read, 0, 256);

                while (count > 0)
                {
                    String str = new String(read, 0, count);
                    Out += str;
                    count = sr.Read(read, 0, 256);
                }
            }
        }
        catch (ArgumentException ex)
        {
            Out = string.Format("HTTP_ERROR :: The second HttpWebRequest object has raised an Argument Exception as 'Connection' Property is set to 'Close' :: {0}", ex.Message);
        }
        catch (WebException ex)
        {
            Out = string.Format("HTTP_ERROR :: WebException raised! :: {0}", ex.Message);
        }
        catch (Exception ex)
        {
            Out = string.Format("HTTP_ERROR :: Exception raised! :: {0}", ex.Message);
        }

        return Out;
    }

但我仍然收到回复 "The remote server returned an error: (404) Not Found"。有人知道我错过了什么吗?

我找到了解决方案。问题出在 Jira 的权限上。在与管理员仔细检查后,我的代码完美运行。