<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: create new webhooks return bad request in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/create-new-webhooks-return-bad-request/m-p/57242#M31971</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/21365"&gt;@dmeneghello&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your JSON, the last part that says "--optional" shouldn't be there. That was included in our sample code to show that you don't need that line, but it's confusing to show that in the sample. We'll remove it in the next rev of the documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change that last part to&lt;/P&gt;&lt;PRE&gt;	"status": "active"&lt;/PRE&gt;&lt;P&gt;and you should be fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Mar 2017 18:53:38 GMT</pubDate>
    <dc:creator>Aaron</dc:creator>
    <dc:date>2017-03-13T18:53:38Z</dc:date>
    <item>
      <title>create new webhooks return bad request</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/create-new-webhooks-return-bad-request/m-p/57230#M31959</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I'm a C# developer i need to use webhooks to get some stuff after the gethostpage with redirect.&lt;/P&gt;&lt;P&gt;Everything&amp;nbsp;it's fine if i use GET ( get events, get my webhooks ), but when i'm going to create a new webhook i get a ""The remote server returned an error: (400) Bad Request."&amp;nbsp;for sure it's a stupid thing but i'm stucked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The request&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; 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;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the json that i'm using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{
  "url": "https://requestb.in/13u2z821",
  "eventTypes": [
    "net.authorize.payment.authcapture.created",
    "net.authorize.customer.created",
    "net.authorize.customer.paymentProfile.created",
    "net.authorize.customer.subscription.expiring"
  ],
  "status": "\"active\"--optional"
}&lt;/PRE&gt;&lt;P&gt;It's working well for any GET request but i always get "bar request" i tried with webclient also.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use requestb.in to test it ( http and https return OK )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2017 13:21:33 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/create-new-webhooks-return-bad-request/m-p/57230#M31959</guid>
      <dc:creator>dmeneghello</dc:creator>
      <dc:date>2017-03-11T13:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: create new webhooks return bad request</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/create-new-webhooks-return-bad-request/m-p/57242#M31971</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.developer.cybersource.com/t5/user/viewprofilepage/user-id/21365"&gt;@dmeneghello&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your JSON, the last part that says "--optional" shouldn't be there. That was included in our sample code to show that you don't need that line, but it's confusing to show that in the sample. We'll remove it in the next rev of the documentation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Change that last part to&lt;/P&gt;&lt;PRE&gt;	"status": "active"&lt;/PRE&gt;&lt;P&gt;and you should be fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 18:53:38 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/create-new-webhooks-return-bad-request/m-p/57242#M31971</guid>
      <dc:creator>Aaron</dc:creator>
      <dc:date>2017-03-13T18:53:38Z</dc:date>
    </item>
  </channel>
</rss>

