Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 授权.Net创建新WebHook时出错_C#_Authorize.net_Authorize.net Webhooks - Fatal编程技术网

C# 授权.Net创建新WebHook时出错

C# 授权.Net创建新WebHook时出错,c#,authorize.net,authorize.net-webhooks,C#,Authorize.net,Authorize.net Webhooks,我是一名C#开发人员,我需要在使用重定向的gethostpage之后使用Webhook获取一些内容。 如果我使用GET(获取事件,获取我的webhook),一切都很好,但是当我要创建一个新的webhook时,我得到了一个“远程服务器返回了一个错误:(400)错误的请求。”当然这是一件愚蠢的事,但我被卡住了 有什么建议吗 请求 byte[] encoded = System.Text.Encoding.Default.GetBytes(apiLogin + ":" + transactionKe

我是一名C#开发人员,我需要在使用重定向的gethostpage之后使用Webhook获取一些内容。 如果我使用GET(获取事件,获取我的webhook),一切都很好,但是当我要创建一个新的webhook时,我得到了一个“远程服务器返回了一个错误:(400)错误的请求。”当然这是一件愚蠢的事,但我被卡住了

有什么建议吗

请求

 byte[] encoded = System.Text.Encoding.Default.GetBytes(apiLogin + ":" + transactionKey);
        string base64 = System.Convert.ToBase64String(encoded);

        var isPost = !string.IsNullOrWhiteSpace(json);

        var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
        httpWebRequest.ContentType = "application/json; charset=utf-8";
        httpWebRequest.Method = isPost ? "POST" : "GET";
        httpWebRequest.Headers.Add("Authorization", "Basic " + base64);
        httpWebRequest.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);


        if (isPost)
        {
            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(json);
                streamWriter.Flush();
            }

        }

        string result = null;

        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {

            result = streamReader.ReadToEnd();
            return result;
        }


        return result;

我正在尝试文档中的JSON示例

发现,在使用“post”webhooks之前,需要在merchant panel中创建一个签名,“get”也可以不这样做

您是否查看了从您发送到服务器的实际URL,例如使用Fiddler?什么URL和标题是预期的,哪些URL和标题是由您发送的?发现,在使用“post”Webhook之前,需要在merchant panel中创建一个签名,“get”也不需要这样做,如果您深入到错误消息中,它会告诉您这是您需要做的。我最近遇到了同样的错误,在错误消息中是我需要修复它的线索。