Xpace Delete Documents

Delete Document

To delete all documents, a single or multiple documents or existing object inside a document.

  • URL

              https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
            
  • Methods & Params

    This method is to delete all documents inside a collection. You can delete a single doceumnt by ID or multiple documents seprated by a comma ( , ). You can also delete part of a single docuemnt.

    Request Method:

    DELETE

    Required Params:

    • appid key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by a colon (:). You can get the appid from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.
    • type key must be provided to determain what type of data is needed. Current values are data for requesting text data and media for requesting files and images.
    • request key must be provided in case of deleteing all documents or certain documents when using the optional parameters below.
    headers: { ... 
    'Content-Type': 'application/json'
    ... }

    body: { ...
    appid=[string:string]
    type=[string]
    request=[string]
    ... }

    Optional Params:

    • Authorization header is need if the data needed is restricted. Read more about authorization by clicking here
    • id key is important if you want to delete a whole document. You can delete many documents by seprating their IDs with a comma ( , ). You must provide record key in order to selete part of the document.
    • record key is important if you want to delete a value inside existing object. You must provide only one id key to be able to use it. You can't use this parameters with multible documents.
    headers: { ... 
    'Authorization': 'Bearer <...token...>'
    ... }
    body: { ...
    id=[json]
    record=[string]
    ... }
  • Success Response:

    If the request was accepted and the document was created successfully, you'll get the id of the inserted document.

    Response Code: 200
    Content:
    { 
    "success": true
    "data": "Requested data has been deleted"
    }
  • Error Response:

    In case of error response, you'll get a response error code, internal error code and a message explianing the error type.

    Response Code: 400, 401 or 406
    Content:
    { 
    "success": false
    "data": {
    "Code: [XBGRL0000]"
    "Message: ...."
    }
    }
  • JavaScript Example to delete all documents inside a collection jQuery :

    function send() {
      var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/"
      var parameters = {
        appid: 'abs23...3cb:web',
        type: 'data',
        request: 'settings'
      }
    
      $.ajax({
        url: url,
        type: 'delete',
        dataType: 'json',
        data: parameters,
        success: function (data) {
          console.log(data)
        }
      });
    }
            
  • JavaScript Example to delete one or more documents inside a collection jQuery :

    function send() {
      var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/"
      var parameters = {
        appid: 'abs23...3cb:web',
        type: 'data',
        request: 'settings',
        id: 'abd123, abs234'
      }
    
      $.ajax({
        url: url,
        type: 'delete',
        dataType: 'json',
        data: parameters,
        success: function (data) {
          console.log(data)
        }
      });
    }
            
  • JavaScript Example to delete an object inside existing document using jQuery :

    // Object in databse
    {
      _id: "abd123",
      user: {
        profile: {
          name: "user name",
          email: "user email",
          settings: {
            autoLogin: true
          }
        }
      }
    }
    
    // The result of the object in database we want to acheive
    {
      _id: "abd123",
      user: {
        profile: {
          name: "user name",
          email: "user email"
      }
    }
    
    // Parcial value we want to update
    var data = false
    
    function send() {
      var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/"
      var parameters = {
        appid: 'abs23...3cb:web',
        type: 'data',
        request: 'settings',
        id: 'abd123',
        record: 'user-profile-settings'
      }
    
      $.ajax({
        url: url,
        type: 'delete',
        dataType: 'json',
        data: parameters,
        success: function (data) {
          console.log(data)
        }
      });
    }
    
    // Result
    {
      "success": true,
      "data": "Requested data has been deleted"
    }
            
  • iOS Example using Almofire :

              ... soon ...
            
  • Android Example:

              ... soon ...
            

Delete Media

To delete a file or an image.

  • URL

              https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/
            
  • Methods & Params

    This method is to delete a file or an image. It's also going to delete resized images if the image you want to deleted has been resized. This methos can accept only one file per request.

    Request Method:

    DELETE

    Required Params:

    • appid key must be presented to access your data. Each project has it's own unique id for different platforms such as "web", "iOS", etc... You must provide the platform key after the appid by seperate them by a colon (:). You can get the appid from your account's control panel. You can reset one or all keys but you have to update your requests by the new generated keys.
    • type key must be provided to determain what type of data is needed. Current values are data for requesting text data and media for requesting files and images.
    • request key must be provided to delete files.
    headers: { ... 
    'Content-Type': 'application/json'
    ... }

    body: { ...
    appid=[string:string]
    type=[string]
    request=[string]
    ... }

    Optional Params:

    No optional parameters so far.

  • Success Response:

    If the request was accepted and the document was created successfully, you'll get the id of the inserted document.

    Response Code: 200
    Content:
    { 
    "success": true
    "data": "Requested data has been deleted"
    }
  • Error Response:

    In case of error response, you'll get a response error code, internal error code and a message explianing the error type.

    Response Code: 400, 401 or 406
    Content:
    { 
    "success": false
    "data": {
    "Code: [XBGRL0000]"
    "Message: ...."
    }
    }
  • JavaScript Example to delete existing file using jQuery :

    function send() {
      var url = "https://api.xbuffer.net/client/<..user_name..>/<..project_name..>/"
      var file = "my_folder/inside_folder/file01.jpg"
      var parameters = {
        appid: 'abs23...3cb:web',
        type: 'media',
        request: file
      }
    
      $.ajax({
        url: url,
        type: 'delete',
        dataType: 'json',
        data: parameters,
        success: function (data) {
          console.log(data)
        }
      });
    }
    
    // Result
    {
      "success": true,
      "data": "Requested data has been deleted"
    }
            
  • iOS Example using Almofire :

              ... soon ...
            
  • Android Example:

              ... soon ...