AnsweredAssumed Answered

PAPI : 400 Bad request while adding rules

Question asked by krish M on Jun 10, 2015
Latest reply on Jun 10, 2015 by krish M

Hi,

      I want to update the default rule/behaviours. Here is my request,

    url="http://private-anon-ca2719dc5-akamaiopen2lunapapiproduction.apiary-mock.com/papi/v0/properties/prp_173136/versions/3/rules/?contractId=ctr_1-1TJZH5&groupId=grp_15225"

 

                    Var req = (HttpWebRequest)WebRequest.Create(url);

                    req.Method = "PUT";

                    req.KeepAlive = true;

                    req.ContentType = "application/vnd.akamai.papirules.latest+json";

                    req.Host = "www.akab-v3rlrjpehs3gpoqd-7kxmfrmdc3e7o5lu.luna.akamaiapis.net";

                    req.Credentials=new NetworkCredential("luna_username","luna_pwd");

 

                    IWebProxy proxy = new WebProxy(new Uri("proxyURL"));

                    proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    req.Proxy = proxy;

                    req.UseDefaultCredentials = true;

                    req.Headers.Add("If-Match", "etag");

                    var credentials = new ClientCredential("clientToken", "accessToken", "scret");

 

                    var signer = new EdgeGridV1Signer();

 

                    var postData=@"{\"name\":\"default\",\"behaviors\":[{\"name\":\"origin\",\"options\":{\"type\":\"customer\",\"forwardhostheader\":\"requesthostheader\",\"cachekeyhostname\":\"originhostname\",\"compression\":\"on\",\"tcip_enabled\":\"off\",\"http_port\":\"80\",\"hostname\":\"origin.example.com\"}"},{\"name\":\"cpcode\",\"options\":{\"cpcode\":{\"id\":\"373112\"}}},{\"name\":\"caching\",\"options\":{\"behavior\":\"no-store\"}},{\"name\":\"sureroute\",\"options\":{\"sr_enabled\":\"true\",\"sr_type\":\"performance\",\"sr_race_stat_ttl\":\"30m\",\"sr_force_ssl_fw\":\"false\",\"sr_to_host_status\":\"incoming_hh\",\"sr_test_object_url\":\"/health\"}},{\"name\":\"tiereddistribution\",\"options\":{\"status\":\"true\",\"tdmap\":\"ch2\"}},{\"name\":\"prefetching\",\"options\":{\"enabled\":\"on\"}},{\"name\":\"allowpost\",\"options\":{\"allow\":\"on\",\"allow_without_content_length\":\"off\"}},\"name\":\"reporting\",\"options\":\"host_enabled\":\"off\",\"referer_enabled\":\"off\",\"useragent_enabled\":\"on\",\"acceptlang_enabled\":\"off\",\"cookie_mode\":\"off\"}},{\"name\":\"rum\",\"options\":{\"status\":\"on\"}}]}";


                    var bytes = Encoding.Default.GetBytes(postData);

                  req.ContentLength = bytes.Length;

                Stream bodyStream = new MemoryStream(bytes);

                signer.Sign(req, credentials, bodyStream);

                var stream = req.GetRequestStream();

                stream.Write(bytes, 0, bytes.Length);

                stream.Close();

 

                var response = req.GetResponse();

 

 

whats wrong in this request?

 

Thanks

krish

Outcomes