title: Update (PUT) a JSON object with ajax - PrestaShop
body: <p>I am trying to update a JSON object (e.g: customer). But, I have the following error:</p>
  
  <blockquote>
    <p>"NetworkError: 405 Method Not Allowed - <a href="http://prestashop/api/" rel="nofollow">http://prestashop/api/</a>..."</p>
  </blockquote>
  
  <p>This is my code (<em>index.js</em>):</p>
  
  <pre><code>var testWebService = angular.module('testWebService', []);
  
  testWebService.controller('testWebServiceCtrl', function ($scope, $http) {
  
      var $baseDir = "http://prestashop/api";
      var $objectDir = "customers";
      var $idObjectDir = "1";
      var $keyDir = "F517VWPRREG7TA25DEY8UIZT8V79E5OV";
      var $urlDir = $baseDir + "/" + $objectDir + "/" + $idObjectDir + "?ws_key=" + $keyDir + "&amp;output_format=JSON";
  
      // TEST DE LA METHODE PUT SUR L ID D UN CUSTOMER
      $.ajax({
          type: "PUT",
          url: $urlDir,
          dataType: "json",
          async: false,
          contentType: "application/json; charset=utf-8",
          data: {"id": "93"},
          crossDomain: true,
          success: function () { 
              console.log("Ok PUT");
          },
          error: function() {
              console.log("Erreur PUT");
          }
      });
  });
  </code></pre>
  
  <p>Before, I tried to GET the id of an object (same: customer) and I succeeded with an almost similar method.
  I precise that I gave rights about "<em>customer</em>" in Advanced Settings / webservice (for method GET, PUT, POST ...).</p>
  
  <p>Thanks in advance for your help, I tried so many things, but whitout success.</p>
  
  <p>PS: If you have any suggestion about my code to "<em>clean</em>" it, you were pleased.</p>
  
  <p>My webservice JSON:</p>
  
  <pre><code>{"customer":{"id":1,"id_default_group":"3","id_lang":"1","newsletter_date_add":"2013-12-13 08:19:15","ip_registration_newsletter":"","last_passwd_gen":"2015-06-08 03:38:27","secure_key":"7036cdf99ea12125ad1b3789f298f686","deleted":"0","passwd":"2e372235eb5213bc004ce72bcfef16a2","lastname":"DOE","firstname":"John","email":"pub@prestashop.com","id_gender":"1","birthday":"1970-01-15","newsletter":"1","optin":"1","website":"","company":"","siret":"","ape":"","outstanding_allow_amount":"0.000000","show_public_prices":"0","id_risk":"0","max_payment_days":"0","active":"1","note":"","is_guest":"0","id_shop":"1","id_shop_group":"1","date_add":"2015-06-08 09:38:27","date_upd":"2015-06-08 09:38:27","associations":{"groups":[{"id":"3"}]}}}
  </code></pre>
  
  <p>EDIT:
  When I tried with the method GET, I did:</p>
  
  <pre><code>$.ajax({
      type: "GET",
      url: $urlDir,
      dataType: "json",
      async: false,
      success: function (data) { 
          $scope.customer1 = data;
          console.log("Ok GET");
          console.log(data);
      },
      error: function() {
          console.log("Erreur GET");
      }
  });
  </code></pre>