Search Posts

HTTP POST error possibly unhandled rejection

I am using Kibana and Elasticsearch with Docker. I create a Kibana plugin which gives the user the possibility to update any index in the ES.
The plugin developed works in my local machine, but in the container I got this error in my console:

POST:http://localhost:5600/api/my_discover/index/.kibana/doc/config:6.2.4/%7B%22type%22:%22config%22,%22updated_at%22:%222018-08-14T12:35:15.616Z%22,%22config%22:%22%7B/%22buildNum/%22:16627,/%22xPackMonitoring:showBanner/%22:true%7D%22%7D
404 (Not Found) Possibly unhandled rejection:
{“data”:{“statusCode”:404,”error”:”Not
Found”},”status”:404,”config”:{“method”:”POST”,”transformRequest”:[null],”transformResponse”:[null],”jsonpCallbackParam”:”callback”,”url”:”../api/my_discover/index/.kibana/doc/config:6.2.4/{“type”:”config”,”updated_at”:”2018-08-14T12:35:15.616Z”,”config”:”{“buildNum”:16627,”xPackMonitoring:showBanner”:true}”}”,”headers”:{“Accept”:”application/json,
text/plain, /“,”kbn-version”:”6.2.4″}},”statusText”:”Not Found”}

My controller:

.controller('editHit', function($http) {
  this.hit = JSON.parse(sessionStorage.getItem('SELECTED_HIT'));
  // Edit the hit
  this.edit = function () {
    // Hit is an object: _id, _index, _score, _source(dataModel), _type
    let doc = JSON.stringify(this.hit._source);
    $http.post(`../api/my_discover/index/${this.hit._index}/${this.hit._type}/${this.hit._id}/${doc}`).then((response) => {
     if(response.status === 200){
       alert("Modification done !");
     }
});

My API:

// This API used to do update a hit
  server.route({
    path: '/api/my_discover/index/{name}/{type}/{id}/{doc}',
    method: 'POST',
    handler(req, reply) {
      let doc = JSON.parse(req.params.doc)
      client.update({
        index: req.params.name,
        type: req.params.type,
        id: req.params.id,
        body: {
          doc: doc
        },
        refresh: true
      }, function (err,response) {
        reply(response);
      });
    }
  });

What’s makes me crazy, like I said, the POST works perfectly in my local machine but in the container no! The GET methods (to get list of index for example) work perfectly in both. I can’t find any explanation.
I’ll appreciate any helps guys ^^

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.